コード例 #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
コード例 #2
0
ファイル: auth.py プロジェクト: YunusovSamat/MyChild
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
コード例 #3
0
ファイル: auth.py プロジェクト: YunusovSamat/MyChild
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
コード例 #4
0
 def check_password(self, password: str) -> bool:
     return security.verify_password(self.salt + password,
                                     self.hashed_password)
コード例 #5
0
 def check_secret(self, secret: str) -> bool:
     return security.verify_password(self.salt + secret, self.hashed_secret)
コード例 #6
0
def test_get_password_hash_and_verify_password():
    hashed_p = get_password_hash("test")
    assert verify_password("test", hashed_p)