21 lines
435 B
Python
21 lines
435 B
Python
import flask
|
|
from flask_login import (LoginManager, UserMixin)
|
|
|
|
class User(UserMixin):
|
|
def __init__(self, id):
|
|
super().__init__()
|
|
self.id = id
|
|
|
|
login_manager = LoginManager()
|
|
|
|
@login_manager.user_loader
|
|
def user_loader(id):
|
|
if id == "admin":
|
|
user = User(id)
|
|
return user
|
|
return
|
|
|
|
@login_manager.unauthorized_handler
|
|
def redirect():
|
|
return flask.redirect(flask.url_for("pages.login_page"))
|