websauna.system.user.credentialactivityservice module

Password reset.

class websauna.system.user.credentialactivityservice.DefaultCredentialActivityService(request)[source]

Bases: object

Handle password reset process and such.

create_forgot_password_request(email, location=None)[source]

Create a new email activation token for a user and produce the following screen.

  • Sets user password reset token

  • Sends out reset password email

  • The existing of user with such email should be validated beforehand

Parameters
  • email (str) – User email.

  • location (Optional[str]) – URL to redirect the user after the password request.

Return type

Response

Returns

Redirect to location.

Raise

CannotResetPasswordException if there is any reason the password cannot be reset. Usually wrong email.

get_user_for_password_reset_token(activation_code)[source]

Get a user by activation token.

Parameters

activation_code (str) – User activation code.

Return type

InterfaceClass

Returns

User for the given activation_code.

reset_password(activation_code, password, location=None)[source]

Perform actual password reset operations.

User has following password reset link (GET) or enters the code on a form.

Parameters
  • activation_code (str) – Activation code provided by the user.

  • password (str) – New user password.

  • location (Optional[str]) – URL to redirect the user after the password request.

Return type

Response

Returns

Redirect to location.

Raise

HTTPNotFound if activation_code is not found.