-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80f5916
commit 0e6cb53
Showing
12 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from fastapi import HTTPException, Cookie | ||
from tools import SessionConfig, InternalConfig | ||
from tools import users_collection, sessions_collection | ||
import logging | ||
|
||
|
||
async def get_pub_user( | ||
session_token: str = Cookie(default=None, alias=SessionConfig.auto_cookie_name) | ||
): | ||
if not session_token: | ||
logging.debug("No session token") | ||
raise HTTPException(status_code=401) | ||
session = sessions_collection.find_one({"session_token": session_token}) | ||
if not session: | ||
logging.debug("No session found") | ||
raise HTTPException(status_code=401) | ||
user = users_collection.find_one( | ||
{"_id": session["user_id"]}, InternalConfig.internal_columns | ||
) | ||
if not user: | ||
logging.debug("No user for session found") | ||
raise HTTPException(status_code=401) | ||
return user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from fastapi import APIRouter, Depends | ||
from api.dependencies.authenticated import get_pub_user | ||
|
||
|
||
router = APIRouter( | ||
prefix="/profile", | ||
tags=["Profile"], | ||
dependencies=[Depends(get_pub_user)], | ||
) | ||
|
||
|
||
@router.get("/") | ||
async def profile(user: dict = Depends(get_pub_user)): | ||
""" | ||
# Get Profile Information | ||
## Description | ||
This endpoint is used to get the public profile information of the user. | ||
""" | ||
return user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
from .db import users_collection, sessions_collection, insecure_cols | ||
from .conf import SignupConfig, EmailConfig, SessionConfig, InternalConfig | ||
from .db import users_collection, sessions_collection | ||
from .conf import ( | ||
SignupConfig, | ||
EmailConfig, | ||
SessionConfig, | ||
InternalConfig, | ||
AccountFeaturesConfig, | ||
) | ||
from .mail import send_email, broadcast_emails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters