<s> from django . contrib . auth import get_user_model <EOL> from django . contrib . auth . backends import ModelBackend <EOL> class EmailAuthBackend ( ModelBackend ) : <EOL> """<STR_LIT>""" <EOL> def authenticate ( self , email = None , password = None ) : <EOL> UserModel = get_user_model ( ) <EOL> try : <EOL> user = UserModel . objects . get ( email = email ) <EOL> if user . check_password ( password ) : <EOL> return user <EOL> except UserModel . DoesNotExist : <EOL> UserModel ( ) . set_password ( password ) </s>
