示例#1
0
文件: auth.py 项目: troyp/gleebox
    def test_it(self):
        from gleebox.lib import auth
        token = auth.issue_token(26, issue_time=1)
        assert(token == '12e06a79585afb82bb8cbceaf5a1030c')

        id = auth.decode_token(token).split('|')
        assert(id[0] == '26')
示例#2
0
 def get(self):
     token = self.request.params.get('token')
     if not token:
         token = self.request.cookies.get('token')
     id = auth.decode_token(token).split('|')[0]
     acct = account.get(id)
     if acct:
         acct['token'] = token
     else:
         raise ApiException('User not found')
     return {'user': acct.data}
示例#3
0
文件: account.py 项目: troyp/gleebox
 def get(self):
     token = self.request.params.get('token')
     if not token:
         token = self.request.cookies.get('token')
     id = auth.decode_token(token).split('|')[0]
     acct = account.get(id)
     if acct:
         acct['token'] = token
     else:
         raise ApiException('User not found')
     return {'user': acct.data}
示例#4
0
文件: __init__.py 项目: troyp/gleebox
 def _wrap(*args, **kw):
     try:
         if (args[0].request and args[0].request.params.get('token')) or args[0].request.cookies.get('token'):
             token = args[0].request.params.get('token')
             if not token:
                 token = args[0].request.cookies.get('token')
             args[0].user_id = auth.decode_token(token).split('|')[0]
             return {'response': f(*args, **kw)}
         else:
             raise ApiException('No auth token for authed api call')
     except ApiException, e:
         return {'response':'', 'error': str(e)}