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
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
a3efdc87
Commit
a3efdc87
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Add change profile page.
parent
b311fcb9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/auth/forms.py
+18
-2
18 additions, 2 deletions
app/auth/forms.py
app/auth/views.py
+10
-2
10 additions, 2 deletions
app/auth/views.py
app/templates/auth/profile.html.j2
+26
-2
26 additions, 2 deletions
app/templates/auth/profile.html.j2
data_dev.sqlite
+0
-0
0 additions, 0 deletions
data_dev.sqlite
with
54 additions
and
6 deletions
app/auth/forms.py
+
18
−
2
View file @
a3efdc87
from
flask_wtf
import
FlaskForm
from
wtforms
import
StringField
,
PasswordField
,
BooleanField
,
SubmitField
from
wtforms.validators
import
DataRequired
,
Length
,
Email
,
Regexp
,
EqualTo
from
wtforms.validators
import
DataRequired
,
Length
,
Email
,
Regexp
,
EqualTo
,
Optional
from
wtforms
import
ValidationError
from
..models
import
User
...
...
@@ -48,6 +48,22 @@ class PasswordResetRequestForm(FlaskForm):
class
ChangeProfileForm
(
FlaskForm
):
email
=
StringField
(
'
Email
'
,
validators
=
[
DataRequired
(),
Length
(
1
,
64
),
email
=
StringField
(
'
Email
'
,
validators
=
[
Optional
(),
Length
(
1
,
64
),
Email
()])
username
=
StringField
(
'
Username
'
,
validators
=
[
Optional
(),
Length
(
1
,
64
),
Regexp
(
'
^[A-Za-z][A-Za-z0-9_.]*$
'
,
0
,
'
Usernames must have only letters, numbers, dots or
'
'
underscores
'
)])
password
=
PasswordField
(
'
Password
'
,
validators
=
[
Optional
(),
EqualTo
(
'
password2
'
,
message
=
'
Passwords must match.
'
)])
password2
=
PasswordField
(
'
Confirm password
'
,
validators
=
[
Optional
()])
submit
=
SubmitField
(
'
Submit
'
)
def
validate_email
(
self
,
field
):
if
User
.
query
.
filter_by
(
email
=
field
.
data
.
lower
()).
first
():
raise
ValidationError
(
'
Email already registered.
'
)
def
validate_username
(
self
,
field
):
if
User
.
query
.
filter_by
(
username
=
field
.
data
).
first
():
raise
ValidationError
(
'
Username already in use.
'
)
This diff is collapsed.
Click to expand it.
app/auth/views.py
+
10
−
2
View file @
a3efdc87
...
...
@@ -87,7 +87,7 @@ def resend_confirmation():
send_email
(
current_user
.
email
,
'
Confirm Your Account
'
,
'
auth/email/confirm
'
,
user
=
current_user
,
token
=
token
)
flash
(
'
A new confirmation email has benn sent to you by email.
'
)
return
redirect
(
url_for
(
'
main
d
.index
'
))
return
redirect
(
url_for
(
'
main.index
'
))
@auth.route
(
'
/reset
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
...
...
@@ -130,7 +130,15 @@ def password_reset(token):
def
profile
():
form
=
ChangeProfileForm
()
if
form
.
validate_on_submit
():
flash
(
'
It
\'
s just a test, nothing changed.
'
)
flash
(
'
It is just a test, nothing changed.
'
)
if
form
.
username
.
data
:
current_user
.
username
=
form
.
username
.
data
db
.
session
.
add
(
current_user
)
if
form
.
email
.
data
:
current_user
.
email
=
form
.
email
.
data
current_user
.
confirmed
=
False
db
.
session
.
add
(
current_user
)
db
.
session
.
commit
()
return
redirect
(
url_for
(
'
auth.profile
'
))
return
render_template
(
'
auth/profile.html.j2
'
,
form
=
form
,
title
=
'
Profile
'
)
This diff is collapsed.
Click to expand it.
app/templates/auth/profile.html.j2
+
26
−
2
View file @
a3efdc87
...
...
@@ -4,17 +4,41 @@
<div class="col s12">
<div class="card large">
<div class="card-content">
<span class="card-title">
Register
</span>
<span class="card-title">
Change profile
</span>
<form method="POST">
{{ form.hidden_tag() }}
<div class="input-field ">
<i class="material-icons prefix">email</i>
{{ form.email(
class='validate', type='
email
'
) }}
{{ form.email(
type='email', placeholder=current_user.
email) }}
{{ form.email.label }}
{% for error in form.email.errors %}
<span class="helper-text" style="color:red;">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field ">
<i class="material-icons prefix">person</i>
{{ form.username(placeholder=current_user.username) }}
{{ form.username.label }}
{% for error in form.username.errors %}
<span class="helper-text" style="color:red;">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">vpn_key</i>
{{ form.password() }}
{{ form.password.label }}
{% for error in form.password.errors %}
<span class="helper-text" style="color:red;">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">vpn_key</i>
{{ form.password2() }}
{{ form.password2.label }}
{% for error in form.password2.errors %}
<span class="helper-text" style="color:red;">{{ error }}</span>
{% endfor %}
</div>
<div class="card-action">
{{ form.submit(class='btn right') }}
</div>
...
...
This diff is collapsed.
Click to expand it.
data_dev.sqlite
+
0
−
0
View file @
a3efdc87
No preview for this file type
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