'Django allauth return Account Inactive page after login

I am new to programming and I don't fully understand how allauth work and what exactly to do.

I have an application where the user is inactive after signing up and he must click on the confirmation email so that he becomes active.

I tried to configure allauth so that a user can also log in with google, but when a new user logs in he is redirected to a page that says Account Inactive.In admin I can see that it creates an account (inactive) and also an entry in social accounts but it doesn't generate a social application token.

On the other hand when a user that already has an acount tries to log in with google it redirect to allauth sign up page.

And so I don't understand how activation with allauth works. Did I make something wrong with my allauth configuration? Should I edit my login function or something else?



Solution 1:[1]

Take a look at the DefaultAdapter class. There is a method for pre_login that checks if your user is inactive and if they are it immediately redirects them to the account_inactive url.

    def pre_login(
    self,
    request,
    user,
    *,
    email_verification,
    signal_kwargs,
    email,
    signup,
    redirect_url
):
    from .utils import has_verified_email, send_email_confirmation

    if not user.is_active:
        return self.respond_user_inactive(request, user)
....

def respond_user_inactive(self, request, user):
    return HttpResponseRedirect(reverse("account_inactive"))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brant Scalan