mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-12 23:05:12 +00:00

Community authentication 1.0 relied on PostgreSQL connections between all servers, and hasn't been used for years. This includes removing the code that migrates users from the old community authentication system to the new one. This means that any user who has not logged in since 2011 will no longer be able to user their oan account, and have to create a new one.
26 lines
803 B
Python
26 lines
803 B
Python
from django.contrib.auth.models import User
|
|
from django.contrib.auth.backends import ModelBackend
|
|
from django.db import connection
|
|
|
|
from pgweb.core.models import UserProfile
|
|
|
|
# Special version of the authentication backend, so we can handle things like
|
|
# forced lowercasing of usernames.
|
|
class AuthBackend(ModelBackend):
|
|
def authenticate(self, username=None, password=None):
|
|
try:
|
|
user = User.objects.get(username=username.lower())
|
|
|
|
# If user is found, check the password using the django
|
|
# methods alone.
|
|
if user.check_password(password):
|
|
return user
|
|
|
|
# User found but password wrong --> tell django it is wrong
|
|
return None
|
|
except User.DoesNotExist:
|
|
# User not found, so clearly they can't log in!
|
|
return None
|
|
|
|
return None # Should never get here, but just in case...
|