Welcome to UserProfile Database’s documentation!

UserProfile - Main Module

async main.authenticate(user: abc.user = Depends(get_current_user)) tortoise.contrib.pydantic.base.PydanticModel

Authenticates any user per the information stored in the database.

Parameters

user – Takes the User_Pydantic model as an argument.

Returns

Returns the user profile information.

Return type

PydanticModel

See also

This is just a placeholder, and a method for further development.

async main.create_user(user: abc.UserIn) tortoise.contrib.pydantic.base.PydanticModel

Creates a new user profile and stores it in the database.

Parameters

user – Takes the internal user profile model as an argument.

Returns

Returns a PyDantic model.

Return type

PydanticModel

async main.generate_token(form_data: fastapi.security.oauth2.OAuth2PasswordRequestForm = Depends(NoneType)) dict

Generates a jwt for the credentials received.

Parameters

form_data – Takes the OAuth2PasswordRequestForm model as an argument.

Returns

Returns a dictionary of access_token and token_type

Return type

dict

See also

  • This function is enabled only for test purpose.

  • The actual working of the working is done using the endpoint generate-token

  • It is passed as tokenUrl to the fastapi class OAuth2PasswordBearer which is our oauth2_scheme

main.health() dict

Health Check for FileFeeder.

Returns

Health status in a dictionary.

Return type

dict

async main.redirect_index() str

Redirect to documents.

Returns

Redirects / url to /docs

Return type

str

async main.startup_event() None

Runs during startup. Configures custom logging using LogConfig.

Models - Authenticator

async models.authenticator.authenticate_user(username: str, password: str) Union[models.classes.Login, bool]

Authenticates the username and password.

Parameters
  • username – Takes username entered as an argument.

  • password – Takes password entered as an argument.

Returns

Returns the login class if the authentication is successful.

Return type

Login

async models.authenticator.get_current_user(token: str = Depends(OAuth2PasswordBearer))

Gets the current user information.

Parameters

token – Takes the oauth token as an argument.

Returns

Returns a pydantic model.

Models - Classes

class models.classes.CreateLogin(tortoise.models.Model)

Creates a datastructure with keys, id, username and password.

>>> CreateLogin
class models.classes.Login(tortoise.models.Model)

Creates a datastructure with keys, id, username and password_hash.

>>> Login
verify_password(password: str) bool

Verifies encrypted version of the password entered by the user.

Parameters

password – Takes the password entered as an argument.

Returns

Returns a boolean flag with the result of verification.

Return type

bool

Models - Custom Logging

class models.config.LogConfig(pydantic.BaseModel)

Custom log configuration that matches uvicorn log format.

>>> LogConfig

See also

  • LOGGER_NAME should match the name passed to getLogger when this class is used for dictConfig

  • LOG_FORMAT is set to match the format of uvicorn.access logs.

Models - User Models

class models.user_models.CustomModels(tortoise.models.Model)

Creates custom models using pydantic_model_creator for User_Model and User_i_Model.

>>> CustomModels

See also

  • User_Model: Used as supporting model for authentication.

  • User_i_Model: Used only to create the main user profile.

Indices and tables