#NEWLINE# def post( self , request ) : #NEWLINE# #INDENT# '\n        Handle POST requests, managing the user authentication.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# user = User . objects . get ( email = request . POST [ 'email' ] ) #NEWLINE# user = authenticate ( username = user . username , password = request . POST [ 'password' ] ) #NEWLINE# if ( user is not None ) : #NEWLINE# #INDENT# if user . is_active : #NEWLINE# #INDENT# login ( request , user ) #NEWLINE# response = Response ( status . HTTP_200_OK , { #NEWLINE# #INDENT# 'msg' : MESSAGES . get ( 'user_authenticated' , '' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# response = Response ( status . HTTP_400_BAD_REQUEST , { #NEWLINE# #INDENT# 'msg' : MESSAGES . get ( 'inactive_user' , '' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# response = Response ( status . HTTP_400_BAD_REQUEST , { #NEWLINE# #INDENT# 'msg' : MESSAGES . get ( 'bad_login_pwd' , '' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# except User . DoesNotExist : #NEWLINE# #INDENT# response = Response ( status . HTTP_400_BAD_REQUEST , { #NEWLINE# #INDENT# 'msg' : MESSAGES . get ( 'bad_login_pwd' , '' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return self . render ( response )