deps#
Dependencies for the endpoints.
The goal is to create all dependencies using a Config class so that the app can be configured differently for testing and production.
Functions#
Return the token if it is valid, otherwise return None. |
|
Initiate a DB session that will be closed when a request finishes. |
|
|
|
Retrieve the data of the current user from the database. |
|
Prepare the context object used by GraphQL resolvers. |
|
Initiate a DB session that will be closed when a request finishes. |
|
Add the user information to the database. |
filter_valid_token()#
get_async_session()#
get_current_user()#
- async rootski.main.deps.get_current_user(db: sqlalchemy.orm.session.Session = Depends(get_session), email: str = Depends(get_authorized_user_email_or_anon)) rootski.schemas.user.User[source]#
Retrieve the data of the current user from the database.
get_graphql_context()#
- rootski.main.deps.get_graphql_context(request: starlette.requests.Request, db: sqlalchemy.orm.session.Session = Depends(get_async_session), user: rootski.schemas.user.User = Depends(get_current_user)) rootski.gql.context.RootskiGraphQLContext[source]#
Prepare the context object used by GraphQL resolvers.
get_session()#
register_user()#
- rootski.main.deps.register_user(session: sqlalchemy.orm.session.Session, email: str, is_admin: bool = False) rootski.schemas.user.User[source]#
Add the user information to the database.
- Parameters
session – used to check if the user already exists and add the user to the db
email – email of the user
is_admin – sets the “is_admin” field of the user to this value in the db
- Raises
UserAlreadyRegisteredError – if the user is already registered, the caller of this function should have checked this in advance
- Returns
model of the registered user