Handle duplicate emails on confirmation and make the confirmation error page nicer
This commit is contained in:
parent
bd5ebe070b
commit
c738113ca4
3 changed files with 26 additions and 3 deletions
|
@ -358,6 +358,9 @@ def confirm_user_email(code):
|
||||||
|
|
||||||
new_email = code.new_email
|
new_email = code.new_email
|
||||||
if new_email:
|
if new_email:
|
||||||
|
if find_user_by_email(new_email):
|
||||||
|
raise DataModelException('E-mail address already used.')
|
||||||
|
|
||||||
user.email = new_email
|
user.email = new_email
|
||||||
|
|
||||||
user.save()
|
user.save()
|
||||||
|
|
|
@ -259,7 +259,7 @@ def confirm_email():
|
||||||
try:
|
try:
|
||||||
result = model.confirm_user_email(code)
|
result = model.confirm_user_email(code)
|
||||||
except model.DataModelException as ex:
|
except model.DataModelException as ex:
|
||||||
return redirect(url_for('signin'))
|
return render_page_template('confirmerror.html', error_message=ex.message)
|
||||||
|
|
||||||
common_login(result['user'])
|
common_login(result['user'])
|
||||||
|
|
||||||
|
|
20
templates/confirmerror.html
Normal file
20
templates/confirmerror.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
<title>Confirmation error · Quay.io</title>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body_content %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<h2>There was an error confirming your e-mail address.</h2>
|
||||||
|
|
||||||
|
{% if error_message %}
|
||||||
|
<div class="alert alert-danger">{{ error_message }}</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Reference in a new issue