#NEWLINE# def post( self ) : #NEWLINE# #INDENT# supplied_token = self . get_body_argument ( 'token' ) #NEWLINE# match = TokenValidate . validator . match ( supplied_token ) #NEWLINE# if ( not match ) : #NEWLINE# #INDENT# return self . error ( ( ( 1 , 'Token format not recognized' ) , ) ) #NEWLINE# #UNINDENT# sess = Session ( ) #NEWLINE# token_name = match . group ( 'token_name' ) #NEWLINE# token_secret = match . group ( 'token_secret' ) #NEWLINE# owner = User . get ( token_secret , name = match . group ( 'name' ) ) #NEWLINE# token = UserToken . get ( sess , owner , token_name ) #NEWLINE# if ( token is None ) : #NEWLINE# #INDENT# return self . error ( ( ( 2 , 'Token specified does not exist' ) , ) ) #NEWLINE# #UNINDENT# if ( not token . enabled ) : #NEWLINE# #INDENT# return self . error ( ( ( 3 , 'Token is disabled' ) , ) ) #NEWLINE# #UNINDENT# if ( not token . check_secret ( token_secret ) ) : #NEWLINE# #INDENT# return self . error ( ( ( 4 , 'Token secret mismatch' ) , ) ) #NEWLINE# #UNINDENT# return self . success ( { #NEWLINE# #INDENT# 'owner' : owner . username , #NEWLINE# 'identity' : str ( token ) , #NEWLINE# 'act_as_owner' : True , #NEWLINE# 'valid' : True , #NEWLINE# #UNINDENT# } )