Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
5069646b
Commit
5069646b
authored
5 years ago
by
Stephan Porada
Browse files
Options
Downloads
Plain Diff
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
parents
f64b6104
49222eee
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/auth/forms.py
+7
-0
7 additions, 0 deletions
app/auth/forms.py
app/auth/views.py
+14
-3
14 additions, 3 deletions
app/auth/views.py
app/models.py
+14
-0
14 additions, 0 deletions
app/models.py
app/templates/auth/reset_password.html.j2
+17
-0
17 additions, 0 deletions
app/templates/auth/reset_password.html.j2
with
52 additions
and
3 deletions
app/auth/forms.py
+
7
−
0
View file @
5069646b
...
@@ -35,6 +35,13 @@ class RegistrationForm(FlaskForm):
...
@@ -35,6 +35,13 @@ class RegistrationForm(FlaskForm):
raise
ValidationError
(
'
Username already in use.
'
)
raise
ValidationError
(
'
Username already in use.
'
)
class
PasswordResetForm
(
FlaskForm
):
password
=
PasswordField
(
'
New Password
'
,
validators
=
[
DataRequired
(),
EqualTo
(
'
password2
'
,
message
=
'
Passwords must match
'
)])
password2
=
PasswordField
(
'
Confirm password
'
,
validators
=
[
DataRequired
()])
submit
=
SubmitField
(
'
Reset Password
'
)
class
PasswordResetRequestForm
(
FlaskForm
):
class
PasswordResetRequestForm
(
FlaskForm
):
email
=
StringField
(
'
Email
'
,
validators
=
[
DataRequired
(),
Length
(
1
,
64
),
email
=
StringField
(
'
Email
'
,
validators
=
[
DataRequired
(),
Length
(
1
,
64
),
Email
()])
Email
()])
...
...
This diff is collapsed.
Click to expand it.
app/auth/views.py
+
14
−
3
View file @
5069646b
...
@@ -2,7 +2,7 @@ from flask import flash, redirect, render_template, request, url_for
...
@@ -2,7 +2,7 @@ from flask import flash, redirect, render_template, request, url_for
from
flask_login
import
current_user
,
login_required
,
login_user
,
logout_user
from
flask_login
import
current_user
,
login_required
,
login_user
,
logout_user
from
.
import
auth
from
.
import
auth
from
..
import
db
from
..
import
db
from
.forms
import
LoginForm
,
PasswordResetRequestForm
,
RegistrationForm
from
.forms
import
LoginForm
,
PasswordResetForm
,
PasswordResetRequestForm
,
RegistrationForm
from
..email
import
send_email
from
..email
import
send_email
from
..models
import
User
from
..models
import
User
...
@@ -81,6 +81,17 @@ def password_reset_request():
...
@@ -81,6 +81,17 @@ def password_reset_request():
title
=
'
Password Reset
'
)
title
=
'
Password Reset
'
)
@auth.route
(
'
/reset/<token>
'
)
@auth.route
(
'
/reset/<token>
'
,
methods
=
[
'
GET
'
,
'
POST
'
]
)
def
password_reset
(
token
):
def
password_reset
(
token
):
return
'
test
'
if
not
current_user
.
is_anonymous
:
return
redirect
(
url_for
(
'
main.index
'
))
form
=
PasswordResetForm
()
if
form
.
validate_on_submit
():
if
User
.
reset_password
(
token
,
form
.
password
.
data
):
db
.
session
.
commit
()
flash
(
'
Your password has been updated.
'
)
return
redirect
(
url_for
(
'
auth.login
'
))
else
:
return
redirect
(
url_for
(
'
main.index
'
))
return
render_template
(
'
auth/reset_password.html.j2
'
,
form
=
form
,
title
=
'
Password Reset
'
)
This diff is collapsed.
Click to expand it.
app/models.py
+
14
−
0
View file @
5069646b
...
@@ -47,6 +47,20 @@ class User(UserMixin, db.Model):
...
@@ -47,6 +47,20 @@ class User(UserMixin, db.Model):
db
.
session
.
add
(
self
)
db
.
session
.
add
(
self
)
return
True
return
True
@staticmethod
def
reset_password
(
token
,
new_password
):
s
=
Serializer
(
current_app
.
config
[
'
SECRET_KEY
'
])
try
:
data
=
s
.
loads
(
token
.
encode
(
'
utf-8
'
))
except
:
return
False
user
=
User
.
query
.
get
(
data
.
get
(
'
reset
'
))
if
user
is
None
:
return
False
user
.
password
=
new_password
db
.
session
.
add
(
user
)
return
True
@property
@property
def
password
(
self
):
def
password
(
self
):
raise
AttributeError
(
'
password is not a readable attribute
'
)
raise
AttributeError
(
'
password is not a readable attribute
'
)
...
...
This diff is collapsed.
Click to expand it.
app/templates/auth/reset_password.html.j2
+
17
−
0
View file @
5069646b
...
@@ -7,10 +7,27 @@
...
@@ -7,10 +7,27 @@
<span class="card-title">Reset Your Password</span>
<span class="card-title">Reset Your Password</span>
<form method="POST">
<form method="POST">
{{ form.hidden_tag() }}
{{ form.hidden_tag() }}
{% if form.email is defined %}
<div class="input-field">
<div class="input-field">
{{ form.email(class='validate', type='email') }}
{{ form.email(class='validate', type='email') }}
{{ form.email.label }}
{{ form.email.label }}
</div>
</div>
{% endif %}
{% if form.password is defined %}
<div class="input-field">
{{ form.password(class='validate', type='password') }}
{{ form.password.label }}
{% for error in form.password.errors %}
<span class="helper-text" style="color:red;">{{ error }}</span>
{% endfor %}
</div>
{% endif %}
{% if form.password2 is defined %}
<div class="input-field">
{{ form.password2(class='validate', type='password') }}
{{ form.password2.label }}
</div>
{% endif %}
<div class="card-action">
<div class="card-action">
{{ form.submit(class='btn right') }}
{{ form.submit(class='btn right') }}
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment