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
7acb3b40
Commit
7acb3b40
authored
2 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
use hashids in jwt
parent
1f3ca966
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/models.py
+7
-6
7 additions, 6 deletions
app/models.py
with
7 additions
and
6 deletions
app/models.py
+
7
−
6
View file @
7acb3b40
from
app
import
db
,
login
,
mail
,
socketio
from
app
import
db
,
hashids
,
login
,
mail
,
socketio
from
app.converters.vrt
import
normalize_vrt_file
from
app.email
import
create_message
from
datetime
import
datetime
,
timedelta
...
...
@@ -327,7 +327,7 @@ class User(HashidMixin, UserMixin, db.Model):
return
False
if
payload
.
get
(
'
purpose
'
)
!=
'
confirm_user
'
:
return
False
if
payload
.
get
(
'
sub
'
)
!=
self
.
id
:
if
payload
.
get
(
'
sub
'
)
!=
self
.
hash
id
:
return
False
self
.
confirmed
=
True
db
.
session
.
add
(
self
)
...
...
@@ -344,7 +344,7 @@ class User(HashidMixin, UserMixin, db.Model):
'
iat
'
:
utc_now
,
'
iss
'
:
current_app
.
config
[
'
SERVER_NAME
'
],
'
purpose
'
:
'
confirm_user
'
,
'
sub
'
:
self
.
id
'
sub
'
:
self
.
hash
id
}
return
jwt
.
encode
(
payload
,
current_app
.
config
[
'
SECRET_KEY
'
],
algorithm
=
'
HS256
'
)
...
...
@@ -355,7 +355,7 @@ class User(HashidMixin, UserMixin, db.Model):
'
iat
'
:
utc_now
,
'
iss
'
:
current_app
.
config
[
'
SERVER_NAME
'
],
'
purpose
'
:
'
reset_password
'
,
'
sub
'
:
self
.
id
'
sub
'
:
self
.
hash
id
}
return
jwt
.
encode
(
payload
,
current_app
.
config
[
'
SECRET_KEY
'
],
algorithm
=
'
HS256
'
)
...
...
@@ -452,9 +452,10 @@ class User(HashidMixin, UserMixin, db.Model):
return
False
if
payload
.
get
(
'
purpose
'
)
!=
'
reset_password
'
:
return
False
user_id
=
payload
.
get
(
'
sub
'
)
if
user_id
is
None
:
user_
hash
id
=
payload
.
get
(
'
sub
'
)
if
user_
hash
id
is
None
:
return
False
user_id
=
hashids
.
decode
(
user_hashid
)
user
=
User
.
query
.
get
(
user_id
)
if
user
is
None
:
return
False
...
...
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