コード例 #1
0
 def test_current(self):
     with self.app.test_request_context('/'):
         user1 = users.current()
         users.auth(self.user)
         user2 = users.current()
         self.assertTrue(user1.anonymous)
         self.assertEqual(user2.sysid, self.user.sysid)
コード例 #2
0
 def auth(self):
     tokens = self.webclient.receive_tokens(self._auth_code)
     if not (tokens and 'access_token' in tokens):
         return False
     access_token = tokens['access_token']
     user_info = self.webclient.user_info(access_token)
     if not (user_info and 'id' in user_info and 'username' in user_info):
         return False
     user_id = user_info['id']
     username = user_info['username']
     user = self._find_or_create_user(user_id, username)
     users.auth(user)
     return True
コード例 #3
0
 def test_auth(self):
     with self.app.test_request_context('/'):
         users.auth(self.user)
         self.assertTrue(flask.session.permanent)
         self.assertTrue('account' in flask.session)
         self.assertEqual(flask.session['account'], self.user.sysid)