def test_authenticate_using_token(self): user = UserFactory.create() exists, auth_user = User.authenticate(email=user.email, password=UserFactory.get_default_password()) expect(auth_user).not_to_be_null() auth_user = User.authenticate_with_token(token=auth_user.token) expect(auth_user).not_to_be_null()
def test_authenticate_using_token(self): user = UserFactory.create() exists, auth_user = User.authenticate( email=user.email, password=UserFactory.get_default_password()) expect(auth_user).not_to_be_null() auth_user = User.authenticate_with_token(token=auth_user.token) expect(auth_user).not_to_be_null()
def get(self): token = self.request.headers.get("Token", None) if not token: self.set_status(400) self.finish() return user = User.authenticate_with_token(token, expiration=self.application.config.TOKEN_EXPIRATION_IN_MINUTES) if user is None: self.set_status(403) self.finish() return self.set_status(200) self.set_header("Token", user.token) self.set_header("Token-Expiration", user.token_expiration.isoformat()) self.write("OK") self.finish()
def get(self): token = self.request.headers.get("Token", None) if not token: self.set_status(400) self.finish() return user = User.authenticate_with_token( token, expiration=self.application.config.TOKEN_EXPIRATION_IN_MINUTES) if user is None: self.set_status(403) self.finish() return self.set_status(200) self.set_header("Token", user.token) self.set_header("Token-Expiration", user.token_expiration.isoformat()) self.write("OK") self.finish()
def test_authenticate_using_invalid_token(self): auth_user = User.authenticate_with_token(token="12312412414124") expect(auth_user).to_be_null()
def test_authenticate_using_invalid_token(self): auth_user = User.authenticate_with_token(token="12312412414124") expect(auth_user).to_be_null()