From 59e30ed9884990f33408f85cd1c18666e61d5507 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 28 Dec 2020 15:17:13 +0200 Subject: [PATCH] Signup and logout: make sync. --- etebase_fastapi/authentication.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/etebase_fastapi/authentication.py b/etebase_fastapi/authentication.py index 2f5a2f1..df5dc62 100644 --- a/etebase_fastapi/authentication.py +++ b/etebase_fastapi/authentication.py @@ -250,10 +250,9 @@ async def login(data: Login, request: Request): @authentication_router.post("/logout/", status_code=status.HTTP_204_NO_CONTENT, responses=permission_responses) -async def logout(request: Request, auth_data: AuthData = Depends(get_auth_data)): - await sync_to_async(auth_data.token.delete)() - # XXX-TOM - await sync_to_async(user_logged_out.send)(sender=auth_data.user.__class__, request=None, user=auth_data.user) +def logout(request: Request, auth_data: AuthData = Depends(get_auth_data)): + auth_data.token.delete() + user_logged_out.send(sender=auth_data.user.__class__, request=None, user=auth_data.user) @authentication_router.post("/change_password/", status_code=status.HTTP_204_NO_CONTENT, responses=permission_responses) @@ -306,9 +305,8 @@ def signup_save(data: SignupIn, request: Request) -> User: @authentication_router.post("/signup/", response_model=LoginOut, status_code=status.HTTP_201_CREATED) -async def signup(data: SignupIn, request: Request): - user = await sync_to_async(signup_save)(data, request) - # XXX-TOM - data = await sync_to_async(LoginOut.from_orm)(user) - await sync_to_async(user_signed_up.send)(sender=user.__class__, request=None, user=user) +def signup(data: SignupIn, request: Request): + user = signup_save(data, request) + data = LoginOut.from_orm(user) + user_signed_up.send(sender=user.__class__, request=None, user=user) return data