Require package authors to have an email address

This commit is contained in:
rubenwardy 2024-03-05 17:53:47 +00:00
parent a83d3bdbe7
commit 76638ad878
2 changed files with 8 additions and 0 deletions

@ -349,6 +349,10 @@ def handle_create_edit(package: typing.Optional[Package], form: PackageForm, aut
@bp.route("/packages/<author>/<name>/edit/", methods=["GET", "POST"]) @bp.route("/packages/<author>/<name>/edit/", methods=["GET", "POST"])
@login_required @login_required
def create_edit(author=None, name=None): def create_edit(author=None, name=None):
if current_user.email is None:
flash(gettext("You must add an email address to your account and confirm it before you can manage packages"), "danger")
return redirect(url_for("users.email_notifications"))
package = None package = None
if author is None: if author is None:
form = PackageForm(formdata=request.form) form = PackageForm(formdata=request.form)

@ -78,6 +78,10 @@ class EditPackageReleaseForm(FlaskForm):
@login_required @login_required
@is_package_page @is_package_page
def create_release(package): def create_release(package):
if current_user.email is None:
flash(gettext("You must add an email address to your account and confirm it before you can manage packages"), "danger")
return redirect(url_for("users.email_notifications"))
if not package.check_perm(current_user, Permission.MAKE_RELEASE): if not package.check_perm(current_user, Permission.MAKE_RELEASE):
return redirect(package.get_url("packages.view")) return redirect(package.get_url("packages.view"))