Added models and views
This commit is contained in:
22
ref-test/app/tools/auth.py
Normal file
22
ref-test/app/tools/auth.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from .data import load
|
||||
from ..models import User
|
||||
|
||||
from flask import abort, redirect
|
||||
from flask.helpers import url_for
|
||||
from flask_login import current_user
|
||||
|
||||
from functools import wraps
|
||||
|
||||
def require_account_creation(function):
|
||||
@wraps(function)
|
||||
def wrapper(*args, **kwargs):
|
||||
if User.query.count() == 0: return redirect(url_for('views._register'))
|
||||
return function(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
def disable_if_logged_in(function):
|
||||
@wraps(function)
|
||||
def wrapper(*args, **kwargs):
|
||||
if current_user.is_authenticated: return abort(404)
|
||||
return function(*args, **kwargs)
|
||||
return wrapper
|
Reference in New Issue
Block a user