MCPcopy Create free account
hub / github.com/clockworknowledge/menome_processor / get_current_user

Function get_current_user

app/routers/utils.py:21–40  ·  view source on GitHub ↗
(token: str = Depends(oauth2_scheme))

Source from the content-addressed store, hash-verified

19
20# Define the dependency function to get the current user
21async def get_current_user(token: str = Depends(oauth2_scheme)) -> User:
22 credentials_exception = HTTPException(
23 status_code=status.HTTP_401_UNAUTHORIZED,
24 detail="Could not validate credentials",
25 headers={"WWW-Authenticate": "Bearer"},
26 )
27 try:
28 payload = jwt.decode(token, AppConfig.SECRET_KEY, algorithms=[AppConfig.ALGORITHM])
29 username: str = payload.get("sub")
30 if username is None:
31 raise credentials_exception
32 # Here you should get the user from your Neo4j database using the username
33 # and convert it to the UserInDB model.
34
35 user = get_user_from_db(username)
36 if user is None:
37 raise credentials_exception
38 except JWTError:
39 raise credentials_exception
40 return user
41
42# Helper function to convert Neo4j datetime to Python datetime
43def neo4j_datetime_to_python_datetime(neo4j_dt_str: str) -> datetime:

Callers

nothing calls this directly

Calls 1

get_user_from_dbFunction · 0.70

Tested by

no test coverage detected