Adapter#
- class allauth.account.adapter.DefaultAccountAdapter(request=None)#
The adapter class allows you to override various functionality of the
allauth.account
app. To do so, pointsettings.ACCOUNT_ADAPTER
to your own class that derives fromDefaultAccountAdapter
and override the behavior by altering the implementation of the methods according to your own needs.- add_message(request, level, message_template=None, message_context=None, extra_tags='', message=None)#
Wrapper of django.contrib.messages.add_message, that reads the message text from a template.
- authenticate(request, **credentials)#
Only authenticates, does not actually login. See login
- can_delete_email(email_address) bool #
Returns whether or not the given email address can be deleted.
- clean_email(email: str) str #
Validates an email value. You can hook into this if you want to (dynamically) restrict what email addresses can be chosen.
- clean_password(password, user=None)#
Validates a password. You can hook into this if you want to restric the allowed password choices.
- clean_phone(phone: str) str #
Validates a phone number. You can hook into this if you want to (dynamically) restrict what phone numbers can be chosen.
- clean_username(username, shallow=False)#
Validates the username. You can hook into this if you want to (dynamically) restrict what usernames can be chosen.
- confirm_email(request, email_address)#
Marks the email address as confirmed on the db
- format_email_subject(subject) str #
Formats the given email subject.
- generate_email_verification_code() str #
Generates a new email verification code.
- generate_login_code() str #
Generates a new login code.
- generate_password_reset_code() str #
Generates a new password reset code.
- generate_phone_verification_code() str #
Generates a new phone verification code.
- get_email_confirmation_url(request, emailconfirmation)#
Constructs the email confirmation (activation) url.
Note that if you have architected your system such that email confirmations are sent outside of the request context request can be None here.
- get_email_verification_redirect_url(email_address)#
The URL to return to after email verification.
- get_from_email()#
This is a hook that can be overridden to programmatically set the ‘from’ email address for sending emails
- get_login_redirect_url(request)#
Returns the default URL to redirect to after logging in. Note that URLs passed explicitly (e.g. by passing along a next GET parameter) take precedence over the value returned here.
- get_logout_redirect_url(request)#
Returns the URL to redirect to after the user logs out. Note that this method is also invoked if you attempt to log out while no users is logged in. Therefore, request.user is not guaranteed to be an authenticated user.
- get_password_change_redirect_url(request)#
The URL to redirect to after a successful password change/set.
NOTE: Not called during the password reset flow.
- get_phone(user) Tuple[str, bool] | None #
Returns the phone number stored for the given user. A tuple of the phone number itself, and whether or not the phone number was verified is returned.
- get_reauthentication_methods(user)#
The order of the methods returned matters. The first method is the default when using the @reauthentication_required decorator.
- get_reset_password_from_key_url(key)#
Method intended to be overridden in case the password reset email needs to be adjusted.
- get_signup_redirect_url(request)#
Returns the default URL to redirect to directly after signing up.
- get_user_by_phone(phone: str)#
Looks up a user given the specified phone number. Returns
None
if no user was phone.
- is_email_verified(request, email)#
Checks whether or not the email address is already verified beyond allauth scope, for example, by having accepted an invitation before signing up.
- is_login_by_code_required(login) bool #
Returns whether or not login-by-code is required for the given login.
- is_open_for_signup(request)#
Checks whether or not the site is open for signups.
Next to simply returning True/False you can also intervene the regular flow by raising an ImmediateHttpResponse
- new_user(request)#
Instantiates a new User instance.
- phone_form_field(**kwargs)#
Returns a form field used to input phone numbers.
- populate_username(request, user)#
Fills in a valid username, if required and missing. If the username is already present it is assumed to be valid (unique).
- render_mail(template_prefix, email, context, headers=None)#
Renders an email to email. template_prefix identifies the email that is to be sent, e.g. “account/email/email_confirmation”
- save_user(request, user, form, commit=True)#
Saves a new User instance using information provided in the signup form.
- send_password_reset_mail(user, email, context)#
Method intended to be overridden in case you need to customize the logic used to determine whether a user is permitted to request a password reset. For example, if you are enforcing something like “social only” authentication in your app, you may want to intervene here by checking user.has_usable_password
- send_unknown_account_sms(phone: str, **kwargs)#
In case enumeration prevention is enabled, and, a verification code is requested for an unlisted phone number, this method is invoked to send a text explaining that no account is on file.
- send_verification_code_sms(user, phone: str, code: str, **kwargs)#
Sends a verification code.
- set_password(user, password) None #
Sets the password for the user.
- set_phone(user, phone: str, verified: bool)#
Sets the phone number (and verified status) for the given user.
- set_phone_verified(user, phone: str)#
Marks the specified phone number for the given user as verified. Note that the user is already expected to have the phone number attached to the account.