Search code examples
pythondjangocsrfdjango-login

How to make override Django login


I want to override Django-login to make a custom login, but I can't find how.

The reason is that there's an specific situation where I cannot use csrf authentication, so I want to create a custom login, and afterwards, make a security layer that ensures my custom login is secure.

Any ideas?


Solution

  • The answer is in here:

    https://docs.djangoproject.com/en/4.0/topics/auth/default/#how-to-log-a-user-in

    The code was something like:

    user = authenticate(username=username, password=password)
    if user is not None:
        if user.is_active:
            login(request, user)