#NEWLINE# def validate( self , attrs ) : #NEWLINE# #INDENT# user = authenticate ( username = attrs [ 'username' ] , password = attrs [ 'password' ] ) #NEWLINE# if ( user is None ) : #NEWLINE# #INDENT# raise serializers . ValidationError ( 'invalid login' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not user . is_active ) : #NEWLINE# #INDENT# raise serializers . ValidationError ( 'Can not log in as inactive user' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( user . is_staff and overridable ( 'OSCARAPI_BLOCK_ADMIN_API_ACCESS' , True ) ) : #NEWLINE# #INDENT# raise serializers . ValidationError ( 'Staff users can not log in via the rest api' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . instance = self #NEWLINE# return attrs