예제 #1
0
파일: user.py 프로젝트: TheSophon/sophon
 def post(self):
     username, password = (
         self.get_argument("username"), self.get_argument("password")
     )
     if username and password and UserMeta.check_password(username=username,
                                                          password=password):
         self.set_secure_cookie("username", username)
         query_data = UserMeta.query.filter_by(username=username).first()
         session.close()
         self.write({
             "id": query_data.id,
             "username": username,
             "type": query_data.user_type
         })
     else:
         self.write({
             "msg": "Wrong username or password"
         })
예제 #2
0
 def test_check_password_if_not_has_user(self, session):
     with mock.patch.object(UserMeta, "query", session.query_property()) as _query:
         self.assertFalse(UserMeta.check_password("Bob", "chkpasswd"))
예제 #3
0
    def test_check_password_if_has_user(self, session):
        _insert_data = UserMeta(username="******", user_type=2, password="******", public_key="/path/key2.pub")
        session.add(_insert_data)

        with mock.patch.object(UserMeta, "query", session.query_property()) as _query:
            self.assertTrue(UserMeta.check_password("Bob", "chkpasswd"))