Exemplo n.º 1
0
 def test_UpdatePassword(self):
     user_db = UserDB()
     u = user_db.add("jontest", "pass", "Jon Q. Testuser")
     passwd = 'A Test Password'
     self.assertFalse(mainCrypt.check_password_hash(u.passhash, passwd))
     user_db.update_password(u, passwd)
     self.assertTrue(mainCrypt.check_password_hash(u.passhash, passwd))
Exemplo n.º 2
0
 def authenticate(self, username, passwd, remember):
     '''
     Authenticates a user.
     '''
     try:
         users = self.find_user_by_name(username)
         if len(users) < 1:
             return False
         u = users[0]
         if mainCrypt.check_password_hash(u.passhash, passwd):
             u.authenticated = True
             u.active = True
             mainDB.session.commit()
             return login_user(u, remember=remember)
         else:
             u.authenticated = False
             u.active = False
             mainDB.session.commit()
             return False
     except:
         raise
     return False