Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions publications/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,25 @@ def change_useremail(request):
'text': 'You attempted to change your email to an address that is blocked. Please contact support for assistance.'
}
})
messages.error(request, "Invalid email change request.")
return render(request, 'changeuser.html')
if not email_new or email_new == email_old:
messages.error(request, "Invalid email change request.")
return render(request, 'changeuser.html')
return render(request, "error.html", {
'error': {
'class': 'danger',
'title': 'Invalid Email Change!',
'text': 'You attempted to change your email to an address that is invalid. Please enter a valid email address that is different from the current one.'
}
})
if User.objects.filter(email=email_new).exists():
messages.error(request, "This email is already in use.")
return render(request, 'changeuser.html')
return render(request, "error.html", {
'error': {
'class': 'danger',
'title': 'Email Already In Use!',
'text': 'You attempted to change your email to an address that is already in use.'
}
})

token = secrets.token_urlsafe(32)
cache.set(
f"{EMAIL_CONFIRMATION_TOKEN_PREFIX}_{email_new}",
Expand Down