예제 #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
파일: account.py 프로젝트: tomzilla/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}
예제 #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)}