Ejemplo n.º 1
0
    def test_user_email_case_insensitivity(self):
        """
        Emails are by nature case insensitive. This test checks that
        the user model correctly handles this specification.
        :return:
        """
        with self.app.app_context():
            data = {
                'email': '*****@*****.**',
                'password': '******',
                'first': 'First',
                'last': 'Last'
            }
            user = User(**data)
            assert (user.email.islower())

            user = User.create(**data)
            assert (user.email.islower())

            user = User.from_email(data['email'])
            self.assertIsNotNone(user)

            user = User.from_login(data['email'], data['password'])
            self.assertIsNotNone(user)
Ejemplo n.º 2
0
def login():
    user = User.from_login(request.json['email'], request.json['password'])
    return JSONResponse(status_code=200,
                        description='User logged in',
                        data={'token': make_jwt(user)})