示例#1
0
 def fb_login(self):
     fb_token = self.request.params.get('fb_token')
     if fb_token:
         user = account.get_from_fb_token(self.request.params.get('fb_token'))
         if not user:
             user = account.create_fb(fb_token)
         id = user['id']
         token = auth.issue_token(id)
         self.request.response.set_cookie('token', token, max_age=365*86400)
         user['token'] = token
         return {'user': user.data}
     else:
         raise ApiException('missing info')
示例#2
0
文件: account.py 项目: troyp/gleebox
 def fb_login(self):
     fb_token = self.request.params.get('fb_token')
     if fb_token:
         user = account.get_from_fb_token(
             self.request.params.get('fb_token'))
         if not user:
             user = account.create_fb(fb_token)
         id = user['id']
         token = auth.issue_token(id)
         self.request.response.set_cookie('token',
                                          token,
                                          max_age=365 * 86400)
         user['token'] = token
         return {'user': user.data}
     else:
         raise ApiException('missing info')
示例#3
0
 def create(self):
     email = self.request.params.get('email')
     password = self.request.params.get('password')
     facebook_token = self.request.params.get('fb_token')
     if facebook_token or (email and password):
         #create user
         if email and password:
             user = account.create(email, password)
         elif facebook_token:
             user = account.create_fb(facebook_token)
         id = user['id']
         token = auth.issue_token(id)
         user['token'] = token
         self.request.response.set_cookie('token', token, max_age=365*86400)
         return {'user': user.data}
     else:
         raise ApiException('missing info')
示例#4
0
文件: account.py 项目: troyp/gleebox
 def create(self):
     email = self.request.params.get('email')
     password = self.request.params.get('password')
     facebook_token = self.request.params.get('fb_token')
     if facebook_token or (email and password):
         #create user
         if email and password:
             user = account.create(email, password)
         elif facebook_token:
             user = account.create_fb(facebook_token)
         id = user['id']
         token = auth.issue_token(id)
         user['token'] = token
         self.request.response.set_cookie('token',
                                          token,
                                          max_age=365 * 86400)
         return {'user': user.data}
     else:
         raise ApiException('missing info')