inventorymgr/auth.py
def is_password_correct(username: str, password: str) -> bool:
    """Checks whether password is valid for user, tries to avoid timing attacks."""
    user = User.query.filter_by(username=username).first()
    if user is None:
        # We need to prevent timing-based side-channel attacks
        # that could be exploited for user enumeration
        password_hash = _CHECK_HASH_ANYWAY
    else:
        password_hash = user.password

    return check_password_hash(password_hash, password) and user is not None
Checks whether password is valid for user, tries to avoid timing attacks.
Checks whether password is valid for user, tries to avoid timing attacks.
Checks whether password is valid for user tries to avoid timing attacks .
def is_password_correct(username: str, password: str) -> bool:
    user = User.query.filter_by(username=username).first()
    if user is None:
        password_hash = _CHECK_HASH_ANYWAY
    else:
        password_hash = user.password
    return check_password_hash(password_hash, password) and user is not None
def is_password_correct ( username : str , password : str ) -> bool : user = User . query . filter_by ( username = username ) . first ( ) if user is None : password_hash = _CHECK_HASH_ANYWAY else : password_hash = user . password return check_password_hash ( password_hash , password ) and user is not None
Checks whether password is valid for user, tries to avoid timing attacks.
Checks whether password is valid for user tries to avoid timing attacks .
"""Checks whether password is valid for user, tries to avoid timing attacks.""" # We need to prevent timing-based side-channel attacks # that could be exploited for user enumeration
username
str
password
str