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, point settings.ACCOUNT_ADAPTER to your own class that derives from DefaultAccountAdapter 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)#

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_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.

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_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.

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.

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

set_password(user, password) None#

Sets the password for the user.