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

# just for exporting
from flask.ext.login import login_user, logout_user, login_required, current_user

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_message = u"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)