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
11a3e755
Commit
11a3e755
authored
5 years ago
by
Stephan Porada
Browse files
Options
Downloads
Patches
Plain Diff
Add email confirmation
parent
ae11e04c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/models.py
+16
-1
16 additions, 1 deletion
app/models.py
with
16 additions
and
1 deletion
app/models.py
+
16
−
1
View file @
11a3e755
...
@@ -22,16 +22,31 @@ class User(UserMixin, db.Model):
...
@@ -22,16 +22,31 @@ class User(UserMixin, db.Model):
username
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
,
index
=
True
)
username
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
,
index
=
True
)
password_hash
=
db
.
Column
(
db
.
String
(
128
))
password_hash
=
db
.
Column
(
db
.
String
(
128
))
role_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
roles.id
'
))
role_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
roles.id
'
))
confirmed
=
db
.
Column
(
db
.
Boolean
,
default
=
False
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'
<User %r>
'
%
self
.
username
return
'
<User %r>
'
%
self
.
username
password_hash
=
db
.
Column
(
db
.
String
(
128
))
def
generate_confirmation_token
(
self
,
expiration
=
3600
):
s
=
Serializer
(
current_app
.
config
[
'
SECRET_KEY
'
],
expiration
)
return
s
.
dumps
({
'
confirm
'
:
self
.
id
}).
decode
(
'
utf-8
'
)
def
generate_reset_token
(
self
,
expiration
=
3600
):
def
generate_reset_token
(
self
,
expiration
=
3600
):
s
=
Serializer
(
current_app
.
config
[
'
SECRET_KEY
'
],
expiration
)
s
=
Serializer
(
current_app
.
config
[
'
SECRET_KEY
'
],
expiration
)
return
s
.
dumps
({
'
reset
'
:
self
.
id
}).
decode
(
'
utf-8
'
)
return
s
.
dumps
({
'
reset
'
:
self
.
id
}).
decode
(
'
utf-8
'
)
def
confirm
(
self
,
token
):
s
=
Serializer
(
current_app
.
config
[
'
SECRET_KEY
'
])
try
:
data
=
s
.
loads
(
token
.
encode
(
'
utf-8
'
))
except
:
return
False
if
data
.
get
(
'
confirm
'
)
!=
self
.
id
:
return
False
self
.
confirmed
=
True
db
.
session
.
add
(
self
)
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.
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