Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Marcus Andersson
aurweb
Commits
e3231569
Commit
e3231569
authored
Jul 20, 2020
by
Frédéric Mangano-Tarumi
Committed by
Lukas Fleischer
Feb 20, 2021
Browse files
SSO: Port account suspension
Signed-off-by:
Lukas Fleischer
<
lfleischer@archlinux.org
>
parent
0e08b151
Changes
1
Hide whitespace changes
Inline
Side-by-side
aurweb/routers/sso.py
View file @
e3231569
...
...
@@ -41,11 +41,20 @@ async def login(request: Request):
return
await
oauth
.
sso
.
authorize_redirect
(
request
,
redirect_uri
,
prompt
=
"login"
)
def
is_account_suspended
(
conn
,
user_id
):
row
=
conn
.
execute
(
select
([
Users
.
c
.
Suspended
]).
where
(
Users
.
c
.
ID
==
user_id
)).
fetchone
()
return
row
is
not
None
and
bool
(
row
[
0
])
def
open_session
(
conn
,
user_id
):
"""
Create a new user session into the database. Return its SID.
"""
# TODO check for account suspension
# TODO Handle translations.
if
is_account_suspended
(
conn
,
user_id
):
raise
HTTPException
(
status_code
=
403
,
detail
=
'Account suspended'
)
# TODO This is a terrible message because it could imply the attempt at
# logging in just caused the suspension.
# TODO apply [options] max_sessions_per_user
sid
=
uuid
.
uuid4
().
hex
conn
.
execute
(
Sessions
.
insert
().
values
(
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment