#NEWLINE# def authenticate( self , token ) : #NEWLINE# #INDENT# if ( 'serrano' in settings . INSTALLED_APPS ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# token = ApiToken . objects . get_active_token ( token ) #NEWLINE# return token . user #NEWLINE# #UNINDENT# except ApiToken . DoesNotExist : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# ( pk , token ) = token_generator . split ( token ) #NEWLINE# try : #NEWLINE# #INDENT# pk = int ( pk ) #NEWLINE# #UNINDENT# except ( ValueError , TypeError ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# user = User . objects . get ( pk = pk , is_active = True ) #NEWLINE# #UNINDENT# except User . DoesNotExist : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if token_generator . check ( user , token ) : #NEWLINE# #INDENT# return user