aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/authentication/oauth2/models/oauth2token.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-01-20 11:42:49 +0300
committerFrederick Muriuki Muriithi2023-01-20 11:48:30 +0300
commitc0db8ccf1be0d43c437fc9e5090e49329a6b2911 (patch)
treeecb600f941bc8bf3c6868a2a9f8e61940ce1e37e /gn3/auth/authentication/oauth2/models/oauth2token.py
parentc843e14249be425e20dcb8cbb6653e49c22298de (diff)
downloadgenenetwork3-c0db8ccf1be0d43c437fc9e5090e49329a6b2911.tar.gz
auth: Setup the user correctly
* gn3/auth/authentication/oauth2/grants/password_grant.py: Return user rather than boolean * gn3/auth/authentication/oauth2/models/oauth2client.py: provide optional `user` argument to allow flexibility in setting up the client's user * gn3/auth/authentication/oauth2/models/oauth2token.py: Set token and client user correctly * gn3/auth/authentication/oauth2/server.py: Set token user from the request
Diffstat (limited to 'gn3/auth/authentication/oauth2/models/oauth2token.py')
-rw-r--r--gn3/auth/authentication/oauth2/models/oauth2token.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/gn3/auth/authentication/oauth2/models/oauth2token.py b/gn3/auth/authentication/oauth2/models/oauth2token.py
index 70421b4..ce7caae 100644
--- a/gn3/auth/authentication/oauth2/models/oauth2token.py
+++ b/gn3/auth/authentication/oauth2/models/oauth2token.py
@@ -49,9 +49,10 @@ class OAuth2Token(NamedTuple):
return self.revoked
def __token_from_resultset__(conn: db.DbConnection, rset) -> Maybe:
- the_client = client(conn, uuid.UUID(rset["client_id"]))
- the_user = user_by_id(conn, uuid.UUID(rset["user_id"]))
__identity__ = lambda val: val
+ the_user = user_by_id(conn, uuid.UUID(rset["user_id"]))
+ the_client = client(conn, uuid.UUID(rset["client_id"]),
+ the_user.maybe(None, __identity__))
if the_client.is_just() and the_user.is_just():
return Just(OAuth2Token(token_id=uuid.UUID(rset["token_id"]),