Django
प्रमाणीकरण का समर्थन करता है
खोज…
ईमेल प्रमाणीकरण बैकएंड
Django का डिफ़ॉल्ट प्रमाणीकरण username और password फ़ील्ड पर काम करता है। ईमेल प्रमाणीकरण बैकएंड उपयोगकर्ताओं को email और password आधार पर प्रमाणित करेगा।
from django.contrib.auth import get_user_model
class EmailBackend(object):
"""
Custom Email Backend to perform authentication via email
"""
def authenticate(self, username=None, password=None):
user_model = get_user_model()
try:
user = user_model.objects.get(email=username)
if user.check_password(password): # check valid password
return user # return user to be authenticated
except user_model.DoesNotExist: # no matching user exists
return None
def get_user(self, user_id):
user_model = get_user_model()
try:
return user_model.objects.get(pk=user_id)
except user_model.DoesNotExist:
return None
इस प्रमाणीकरण बैकेंड को AUTHENTICATION_BACKENDS सेटिंग में जोड़ें।
# settings.py
AUTHENTICATION_BACKENDS = (
'my_app.backends.EmailBackend',
...
)
Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow