Custom login

i use my own model for my users and i have a custom authenticate and as such i use this setting

AUTHENTICATION_BACKENDS = ['home.backends.MemberBackend']

and it works great because i use it to login in with gmail. But now i cant login in to the django admin site. So was wondering if anyone could explain or link to the answer in docs


from django.contrib.auth.backends import BaseBackend
from .models import Member

class MemberBackend(BaseBackend):
    def authenticate(self, request, email=None, password=None):
            user = Member.objects.get(email=email)

            if user.password == password:
                return user
        except Member.DoesNotExist:

        return None

    def get_user(self, user_id):
            return Member.objects.get(pk=user_id)
        except Member.DoesNotExist:
            return None

Add the default authentication backend back to your setting

there was no other one there before

You’d need to post the code for your MemberBackend for us to be able to figure out what might be wrong.

Done! i added the code

Review the docs for Writing an authentication backend, along with the examples.

Your code only works if you’re doing something extremely silly like storing the passwords in plain text in the database. You normally need to use the check_password function to see if the plain-text password submitted hashes to the same value as what is stored in the database.

yh nvm i fixed it and iam planning to make it so it hashes the passwords.

But thank you for answering and showing me that check_password exists!