summaryrefslogtreecommitdiff
path: root/kosten/app/login.py
blob: 850cc8a5045f8ee9eb31863d3adefaf0e724f3ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from flask_login import LoginManager, UserMixin
from passlib.apps import custom_app_context as pwd_context
from . import app, model

# just for exporting
from flask_login import login_user, logout_user, login_required, current_user

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_message = "Bitte einloggen!"

class User (model.User, UserMixin):
    def check_password(self, pwd):
        return pwd_context.verify(pwd, self.pwd)

    def set_password(self, pwd):
        self.pwd = pwd_context.encrypt(pwd)

@login_manager.user_loader
def load_user(id):
    return User.get(id)