Skip to content

Class tigrbl_auth.backends.PasswordBackend

tigrbl_auth.backends.PasswordBackend

Authenticate a user by username or email plus plaintext password.

Usage

backend = PasswordBackend() user = await backend.authenticate(db, "alice", "pa$$w0rd")

authenticate async

authenticate(db, identifier, password)
Source code in tigrbl_auth/backends.py
90
91
92
93
94
95
96
async def authenticate(
    self, db: AsyncSession, identifier: str, password: str
) -> User:
    row: Optional["User"] = await db.scalar(await self._get_user_stmt(identifier))
    if not row or not verify_pw(password, row.password_hash):
        raise AuthError("invalid username/email or password")
    return row