mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 19:30:00 +00:00
Merge pull request #91 from Open-Anime-Database-Consortium/master
User profile page UI and logic change
This commit is contained in:
commit
03d658fcef
|
@ -72,23 +72,23 @@ class RegisterForm(FlaskForm):
|
||||||
|
|
||||||
|
|
||||||
class ProfileForm(FlaskForm):
|
class ProfileForm(FlaskForm):
|
||||||
email = TextField('New email address', [
|
email = TextField('New Email Address', [
|
||||||
Email(),
|
Email(),
|
||||||
Optional(),
|
Optional(),
|
||||||
Length(min=5, max=128),
|
Length(min=5, max=128),
|
||||||
Unique(User, User.email, 'Email is taken')
|
Unique(User, User.email, 'This email address has been taken')
|
||||||
])
|
])
|
||||||
|
|
||||||
current_password = PasswordField('Current password', [Optional()])
|
current_password = PasswordField('Current Password', [Required()])
|
||||||
|
|
||||||
new_password = PasswordField('New password (confirm)', [
|
new_password = PasswordField('New Password', [
|
||||||
Optional(),
|
Optional(),
|
||||||
EqualTo('password_confirm', message='Passwords must match'),
|
EqualTo('password_confirm', message='Two passwords must match'),
|
||||||
Length(min=6, max=1024,
|
Length(min=6, max=1024,
|
||||||
message='Password must be at least %(min)d characters long.')
|
message='Password must be at least %(min)d characters long.')
|
||||||
])
|
])
|
||||||
|
|
||||||
password_confirm = PasswordField('Repeat Password')
|
password_confirm = PasswordField('Repeat New Password')
|
||||||
|
|
||||||
|
|
||||||
# Classes for a SelectField that can be set to disable options (id, name, disabled)
|
# Classes for a SelectField that can be set to disable options (id, name, disabled)
|
||||||
|
|
|
@ -401,6 +401,11 @@ def profile():
|
||||||
new_password = form.new_password.data
|
new_password = form.new_password.data
|
||||||
|
|
||||||
if new_email:
|
if new_email:
|
||||||
|
# enforce password check on email change too
|
||||||
|
if form.current_password.data != user.password_hash:
|
||||||
|
flask.flash(flask.Markup(
|
||||||
|
'<strong>Email change failed!</strong> Incorrect password.'), 'danger')
|
||||||
|
return flask.redirect('/profile')
|
||||||
user.email = form.email.data
|
user.email = form.email.data
|
||||||
|
|
||||||
if new_password:
|
if new_password:
|
||||||
|
|
|
@ -108,3 +108,7 @@ table.torrent-list thead th.sorting_desc:after {
|
||||||
border: 1px solid rgba(100, 56, 0, 0.8);
|
border: 1px solid rgba(100, 56, 0, 0.8);
|
||||||
background: rgba(200,127,0,0.3);
|
background: rgba(200,127,0,0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.nav-tabs#profileTabs {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
|
@ -4,40 +4,63 @@
|
||||||
{% from "_formhelpers.html" import render_field %}
|
{% from "_formhelpers.html" import render_field %}
|
||||||
|
|
||||||
<h1>Edit Profile</h1>
|
<h1>Edit Profile</h1>
|
||||||
<form method="POST">
|
|
||||||
{{ form.csrf_token }}
|
|
||||||
|
|
||||||
<div class="row">
|
<ul class="nav nav-tabs" id="profileTabs" role="tablist">
|
||||||
<div class="form-group col-md-4">
|
<li role="presentation" class="active">
|
||||||
{{ render_field(form.email, class_='form-control', placeholder='New email address') }}
|
<a href="#password-change" id="password-change-tab" role="tab" data-toggle="tab" aria-controls="profile" aria-expanded="true">Password</a>
|
||||||
</div>
|
</li>
|
||||||
</div>
|
<li role="presentation">
|
||||||
|
<a href="#email-change" id="email-change-tab" role="tab" data-toggle="tab" aria-controls="profile" aria-expanded="false">Email</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane fade active in" role="tabpanel" id="password-change" aria-labelledby="password-change-tab">
|
||||||
|
<form method="POST">
|
||||||
|
{{ form.csrf_token }}
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
{{ render_field(form.current_password, class_='form-control', placeholder='Current password') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
{{ render_field(form.new_password, class_='form-control', placeholder='New password') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
{{ render_field(form.password_confirm, class_='form-control', placeholder='New password (confirm)') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<input type="submit" value="Update" class="btn btn-primary">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="tab-pane fade" role="tabpanel" id="email-change" aria-labelledby="email-change-tab">
|
||||||
|
<form method="POST">
|
||||||
|
{{ form.csrf_token }}
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
{{ render_field(form.email, class_='form-control', placeholder='New email address') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
{{ render_field(form.current_password, class_='form-control', placeholder='Current password') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<input type="submit" value="Update" class="btn btn-primary">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-md-4">
|
|
||||||
{{ render_field(form.current_password, class_='form-control', placeholder='Current password') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-md-4">
|
|
||||||
{{ render_field(form.new_password, class_='form-control', placeholder='New password') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-md-4">
|
|
||||||
{{ render_field(form.password_confirm, class_='form-control', placeholder='New password (confirm)') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<input type="submit" value="Update" class="btn btn-primary">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue