Beispiel #1
0
 def test_user_can_login(self):
     response = self.client.post('/login', data={
         'email': self.user.email,
         'password': '******',
     })
     self.assertEquals(response.status_code, 302)
     session = Session.select().where(Session.user == self.user).first()
     self.assertTrue(self.feature.is_logged(session.token))
Beispiel #2
0
 def get_current_user(self, token):
     session = Session.select().where(Session.token == token).first()
     if session:
         return User.get(User.id == session.user_id)
     return None
Beispiel #3
0
 def is_logged(self, token):
     return Session.select().where(Session.token == token).exists()
Beispiel #4
0
 def test_user_can_logout(self):
     response = self.client.post("/login", data={"email": self.user.email, "password": "******"})
     self.assertEquals(response.status_code, 302)
     session = Session.select().where(Session.user == self.user).first()
     self.feature.logout(session.token)
     self.assertFalse(self.feature.is_logged(session.token))