websauna.system.user.userregistry module¶
Default user object generator.
-
class
websauna.system.user.userregistry.
DefaultEmailBasedUserRegistry
(request)[source]¶ Bases:
object
Default user backend which uses SQLAlchemy to store User models.
Provides default user actions
-
property
Activation
¶ Currently configured User SQLAlchemy model.
- Return type
Type
[InterfaceClass
]- Returns
Class implementing IActivationModel.
-
property
User
¶ Currently configured User SQLAlchemy model.
- Return type
Type
[InterfaceClass
]- Returns
Class implementing IUserModel.
-
activate_user_by_email_token
(token)[source]¶ Get user by a password token issued earlier.
Consume any activation token.
-
can_login
(user)[source]¶ Verify if user is allowed do login.
- Parameters
user (
InterfaceClass
) – User object.- Return type
- Returns
Boolean
-
can_reset_password
(user)[source]¶ Verify if user is allowed to reset their password.
- Parameters
user (
InterfaceClass
) – User object.- Return type
- Returns
Boolean
-
create_email_activation_token
(user)[source]¶ Create activation token for the user to be used in the email
-
get_authenticated_user_by_email
(email, password)[source]¶ Authenticate incoming user using email and password.
-
get_authenticated_user_by_username
(username, password)[source]¶ Authenticate incoming user using username and password.
-
get_by_activation
(activation)[source]¶ Return the User with the given activation.
- Parameters
activation (
InterfaceClass
) – Activation object..- Return type
InterfaceClass
- Returns
User object.
-
get_by_email
(email)[source]¶ Return the User with the given email.
We always compare the lowercase version of User.email and email.
- Parameters
email (
str
) – Email to be used.- Return type
InterfaceClass
- Returns
User object.
-
get_by_username
(username)[source]¶ Return the User with the given username.
We always compare the lowercase version of User.username and username.
- Parameters
username (
str
) – Username to be used.- Return type
InterfaceClass
- Returns
User object.
-
get_groups
(user)[source]¶ Groups for a user.
- Parameters
user (
InterfaceClass
) – User object.- Return type
- Returns
List of groups for this user.
-
get_session_token
(user)[source]¶ Get marker string we use to store reference to this user in authenticated session.
- Parameters
user (
InterfaceClass
) – User object.- Returns
User id.
-
get_user_by_password_reset_token
(token)[source]¶ Get user by a password token issued earlier.
Consume any activation token.
-
get_user_by_session_token
(token)[source]¶ Resolve the authenticated user by a session token reference.
-
reset_password
(user, password)[source]¶ Reset user password and clear all pending activation issues.
- Parameters
user (
InterfaceClass
) – User object,password (
str
) – New password.
-
set_password
(user, password)[source]¶ Hash a password for persistent storage.
Uses password hasher registered in
websauna.system.Initializer.configure_password()
.- Parameters
user (
InterfaceClass
) – User object.password (
str
) – User password.
-
verify_password
(user, password)[source]¶ Validate user password.
Uses password hasher registered in
websauna.system.Initializer.configure_password()
.
-
property