~fnux/meta.sr.ht

ref: 1523a34288ef75828716b82551f545241e9eba7c meta.sr.ht/metasrht/auth/base.py -rw-r--r-- 528 bytes
1523a342Drew DeVault Add user profile information to admin page 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from typing import Optional

from srht.validation import Validation

from metasrht.types.user import User


def get_user(username: str) -> Optional[User]:
    return User.query.filter(
        (User.username == username.lower()) |
        (User.email == username.strip())).one_or_none()


class AuthMethod:
    def user_valid(self, valid: Validation, username: str, password: str) \
            -> bool:
        raise NotImplementedError()

    def prepare_user(self, username: str) -> User:
        raise NotImplementedError()