Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
de257336
Commit
de257336
authored
6 months ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
DSN: Logujeme i email
parent
650bee86
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/email.py
+2
-2
2 additions, 2 deletions
mo/email.py
mo/web/api_dsn.py
+2
-2
2 additions, 2 deletions
mo/web/api_dsn.py
with
4 additions
and
4 deletions
mo/email.py
+
2
−
2
View file @
de257336
...
...
@@ -117,7 +117,7 @@ def gen_dsn_token(user: db.User, rr: Optional[db.RegRequest] = None) -> Optional
return
f
'
{
raw_token
}
-
{
sig
}
'
def
validate_dsn_token
(
token
:
str
)
->
Tuple
[
Optional
[
db
.
User
],
Optional
[
db
.
RegRequest
],
datetime
]:
def
validate_dsn_token
(
token
:
str
)
->
Tuple
[
Optional
[
db
.
User
],
Optional
[
db
.
RegRequest
],
str
,
datetime
]:
secret
=
getattr
(
config
,
'
MAIL_TOKEN_SECRET
'
,
None
)
if
secret
is
None
:
raise
ValueError
(
"
MAIL_TOKEN_SECRET nenastaven
"
)
...
...
@@ -157,7 +157,7 @@ def validate_dsn_token(token: str) -> Tuple[Optional[db.User], Optional[db.RegRe
if
given_sig
!=
correct_sig
:
raise
ValueError
(
"
Nesouhlasí podpis
"
)
return
user
,
rr
,
when
return
user
,
rr
,
email
,
when
def
send_user_email
(
user
:
db
.
User
,
...
...
This diff is collapsed.
Click to expand it.
mo/web/api_dsn.py
+
2
−
2
View file @
de257336
...
...
@@ -106,11 +106,11 @@ def api_email_dsn() -> Response:
app
.
logger
.
info
(
f
'
DSN: Token:
{
token
}
'
)
try
:
user
,
rr
,
when
=
mo
.
email
.
validate_dsn_token
(
token
)
user
,
rr
,
email
,
when
=
mo
.
email
.
validate_dsn_token
(
token
)
user_info
=
f
'
#
{
user
.
user_id
}
'
if
user
is
not
None
else
'
-
'
rr_info
=
f
'
#
{
rr
.
reg_id
}
'
if
rr
is
not
None
else
'
-
'
age
=
mo
.
util_format
.
time_duration_numeric
(
mo
.
now
-
when
)
app
.
logger
.
info
(
f
'
DSN: user=
{
user_info
}
registration=
{
rr_info
}
age=
{
age
}
'
)
app
.
logger
.
info
(
f
'
DSN: user=
{
user_info
}
registration=
{
rr_info
}
email=
{
email
}
age=
{
age
}
'
)
except
ValueError
as
e
:
app
.
logger
.
info
(
f
'
DSN:
{
e
}
'
)
pass
...
...
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