Enable login with email, like the form says
This commit is contained in:
parent
c962005286
commit
7d74003d0d
|
|
@ -2,7 +2,7 @@ import graphene
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import authenticate, login
|
from django.contrib.auth import authenticate, login
|
||||||
from graphene import relay
|
from graphene import relay
|
||||||
|
from users.models import User
|
||||||
# from users.user_signup_login_handler import handle_user_and_verify_products, UNKNOWN_ERROR, EMAIL_NOT_VERIFIED
|
# from users.user_signup_login_handler import handle_user_and_verify_products, UNKNOWN_ERROR, EMAIL_NOT_VERIFIED
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -19,6 +19,13 @@ class BetaLogin(relay.ClientIDMutation):
|
||||||
if settings.ALLOW_BETA_LOGIN:
|
if settings.ALLOW_BETA_LOGIN:
|
||||||
password = kwargs.get('password_input')
|
password = kwargs.get('password_input')
|
||||||
username = kwargs.get('username_input')
|
username = kwargs.get('username_input')
|
||||||
|
|
||||||
|
# Login with email
|
||||||
|
if '@' in username:
|
||||||
|
user = User.objects.get(email=username)
|
||||||
|
if user:
|
||||||
|
username = user.username
|
||||||
|
|
||||||
user = authenticate(username=username, password=password)
|
user = authenticate(username=username, password=password)
|
||||||
if user is None:
|
if user is None:
|
||||||
raise Exception('invalid_credentials')
|
raise Exception('invalid_credentials')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue