SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 0b3ea398 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

allow user to verify own email addresses

parent b455db79
No related branches found
No related tags found
No related merge requests found
...@@ -580,7 +580,6 @@ def _hx_profile_email_toggle_valid(request, email_id): ...@@ -580,7 +580,6 @@ def _hx_profile_email_toggle_valid(request, email_id):
) )
@permission_required_htmx("scipost.can_verify_profile_emails")
def _hx_profile_email_request_verification(request, email_id): def _hx_profile_email_request_verification(request, email_id):
"""Toggle verified/unverified status of ProfileEmail.""" """Toggle verified/unverified status of ProfileEmail."""
profile_email = get_object_or_404(ProfileEmail, pk=email_id) profile_email = get_object_or_404(ProfileEmail, pk=email_id)
...@@ -588,6 +587,14 @@ def _hx_profile_email_request_verification(request, email_id): ...@@ -588,6 +587,14 @@ def _hx_profile_email_request_verification(request, email_id):
if not request.method == "PATCH": if not request.method == "PATCH":
raise BadRequest("Invalid request method") raise BadRequest("Invalid request method")
is_mail_owner = request.user.contributor.profile == profile_email.profile
can_verify_emails = request.user.has_perm("scipost.can_verify_profile_emails")
if not (is_mail_owner or can_verify_emails):
return HTMXResponse(
"You do not have the required permissions to verify this email.",
tag="danger",
)
if not profile_email.verified: if not profile_email.verified:
profile_email.send_verification_email() profile_email.send_verification_email()
messages.success( messages.success(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment