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
a698b722
Commit
a698b722
authored
4 years ago
by
Jiří Setnička
Browse files
Options
Downloads
Patches
Plain Diff
Reset hesla: Po resetování uživatele rovnou přihlásíme
parent
4e17e571
Branches
Branches containing commit
No related tags found
1 merge request
!9
WIP: Zárodek uživatelské části webu a submitování
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/web/auth.py
+8
-7
8 additions, 7 deletions
mo/web/auth.py
with
8 additions
and
7 deletions
mo/web/auth.py
+
8
−
7
View file @
a698b722
...
...
@@ -25,7 +25,8 @@ class LoginForm(FlaskForm):
reset
=
wtforms
.
SubmitField
(
'
Obnovit heslo
'
)
def
after_login
(
user
:
db
.
User
,
url
:
Optional
[
str
]
=
None
):
def
login_and_redirect
(
user
:
db
.
User
,
url
:
Optional
[
str
]
=
None
):
session
[
'
uid
'
]
=
user
.
user_id
if
not
url
:
if
user
.
is_admin
or
user
.
is_org
:
url
=
url_for
(
'
org_index
'
)
...
...
@@ -69,8 +70,7 @@ def login():
app
.
logger
.
info
(
'
Login: Přihlásil se uživatel <%s>
'
,
email
)
mo
.
users
.
login
(
user
)
db
.
get_session
().
commit
()
session
[
'
uid
'
]
=
user
.
user_id
return
after_login
(
user
,
form
.
next
.
data
)
return
login_and_redirect
(
user
,
url
=
form
.
next
.
data
)
return
render_template
(
'
login.html
'
,
form
=
form
)
...
...
@@ -92,8 +92,7 @@ def incarnate(id):
raise
werkzeug
.
exceptions
.
NotFound
()
app
.
logger
.
info
(
'
Login: Uživatel #%s se převtělil na #%s
'
,
g
.
user
.
user_id
,
new_user
.
user_id
)
session
[
'
uid
'
]
=
new_user
.
user_id
return
after_login
(
new_user
)
return
login_and_redirect
(
new_user
)
@app.route
(
'
/user/settings
'
)
...
...
@@ -158,6 +157,8 @@ def reset():
what
=
user
.
user_id
,
details
=
{
'
action
'
:
'
reset-passwd
'
},
)
mo
.
users
.
login
(
user
)
app
.
logger
.
info
(
'
Login: Přihlásil se uživatel <%s> po resetování hesla
'
,
user
.
email
)
db
.
get_session
().
commit
()
flash
(
'
Nové hesl
o úspěšně nastaveno, nyní se můžete přihlásit
'
,
'
success
'
)
return
redirect
(
url_for
(
'
login
'
,
email
=
user
.
email
)
)
flash
(
'
N
astavení n
ové
ho
hesl
a a přihlášení do systému proběhlo úspěšně
'
,
'
success
'
)
return
login_and_redirect
(
user
)
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