~fnux/meta.sr.ht

ref: e929d461b76fb7b17963c864192a975562bf23b6 meta.sr.ht/metasrht/auth/base.py -rw-r--r-- 662 bytes
e929d461Timothée Floure Make password reset logic more generic 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import Optional

from srht.database import db
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()

    def set_user_password(self, user: User, password: str) -> bool:
        raise NotImplementedError()