Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
 def test_authenticate_using_invalid_token(self):
     auth_user = User.authenticate_with_token(token="12312412414124")
     expect(auth_user).to_be_null()
Exemplo n.º 6
0
 def test_authenticate_using_invalid_token(self):
     auth_user = User.authenticate_with_token(token="12312412414124")
     expect(auth_user).to_be_null()