[Multi-User Part 2]: Add login pages and gate access to application behind login wall (#503)

- Make most routes conditional on authentication *if anonymous mode is not enabled*. If anonymous mode is enabled, it scaffolds a default user and uses that for all application interactions.
- Add a basic login page and add routes for redirecting the user if logged in
This commit is contained in:
sabaimran
2023-10-26 10:17:29 -07:00
committed by GitHub
parent 216acf545f
commit a8a82d274a
13 changed files with 327 additions and 59 deletions

View File

@@ -73,8 +73,7 @@ async def create_google_user(token: dict) -> KhojUser:
async def get_user_by_token(token: dict) -> KhojUser:
user_info = token.get("userinfo")
google_user = await GoogleUser.objects.filter(sub=user_info.get("sub")).select_related("user").afirst()
google_user = await GoogleUser.objects.filter(sub=token.get("sub")).select_related("user").afirst()
if not google_user:
return None
return google_user.user