Users¶
users
¶
User management core logic.
Provides business logic for user creation and authentication, independent of the database implementation.
Classes¶
UserAlreadyExistsError
¶
Bases: Exception
Raised when trying to create a user with an existing email.
InvalidCredentialsError
¶
Bases: Exception
Raised when login credentials are invalid.
EmailNotVerifiedError
¶
Bases: Exception
Raised when email is not verified
Functions¶
create_user
¶
create_user(*, users: UserAdapter, email: str, password: str) -> Any
Create a new user with a hashed password.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
users |
UserAdapter
|
User adapter for database operations |
required |
email |
str
|
User's email address |
required |
password |
str
|
Plain text password (will be hashed) |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Created user object |
Raises:
| Type | Description |
|---|---|
UserAlreadyExistsError
|
If a user with the email already exists |
Source code in fastauth/core/users.py
authenticate_user
¶
authenticate_user(*, users: UserAdapter, email: str, password: str) -> Any
Authenticate a user by email and password.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
users |
UserAdapter
|
User adapter for database operations |
required |
email |
str
|
User's email address |
required |
password |
str
|
Plain text password to verify |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Authenticated user object |
Raises:
| Type | Description |
|---|---|
InvalidCredentialsError
|
If email doesn't exist, password is wrong, or user is inactive |
EmailNotVerifiedError
|
If email verification is required but not completed |