Exemple #1
0
def authenticate_user(username: str, password: str):
    user = get_user(username)
    if not user:
        return False
    if not verify_password(password, user.password):
        return False
    return user
Exemple #2
0
async def authenticate_parent(username: str,
                              password: str) -> Union[Parent, bool]:
    db_parent = await crud.get_parent_by_username(username)
    if not db_parent:
        return False
    if not verify_password(password, db_parent.password):
        return False
    return db_parent
Exemple #3
0
async def authenticate_educator(username: str,
                                password: str) -> Union[Educator, bool]:
    db_educator = await crud.get_educator_by_username(username)
    if not db_educator:
        return False
    if not verify_password(password, db_educator.password):
        return False
    return db_educator
Exemple #4
0
 def check_password(self, password: str) -> bool:
     return security.verify_password(self.salt + password,
                                     self.hashed_password)
 def check_secret(self, secret: str) -> bool:
     return security.verify_password(self.salt + secret, self.hashed_secret)
Exemple #6
0
def test_get_password_hash_and_verify_password():
    hashed_p = get_password_hash("test")
    assert verify_password("test", hashed_p)