def login(): # If there are no users, send them to the registration page if User.select().count() == 0: flash("No admins found, please register the first administrator.", "info") return redirect(url_for(".register")) return render_template("admin/login.html")
def register_post(): # Only allow access if logged in or no users are registered if current_user.is_anonymous() and User.select().count() > 0: return current_app.login_manager.unauthorized() name = get_post_value("name") email = get_post_value("email") password = get_post_value("password") errors = register_user(name, email, password) if len(errors) > 0: # This means that an error has occured for e in errors: flash(e, 'danger') return render_template("admin/register.html", name=name, email=email) else: flash("User registered successfully.", "success") return redirect(url_for('.register'))
def register_post(): # Only allow access if logged in or no users are registered if current_user.is_anonymous() and User.select().count() > 0: return current_app.login_manager.unauthorized() name = get_post_value("name") email = get_post_value("email") password = get_post_value("password") errors = register_user(name, email, password) if len(errors) > 0: # This means that an error has occured for e in errors: flash(e, 'danger') return render_template("admin/register.html", name=name, email=email) else: flash("User registered successfully.", "success") return redirect(url_for('.register'))
def register(): # Only allow access if logged in or no users are registered if current_user.is_anonymous() and User.select().count() > 0: return current_app.login_manager.unauthorized() return render_template("admin/register.html")
def login(): # If there are no users, send them to the registration page if User.select().count() == 0: flash("No admins found, please register the first administrator.", "info") return redirect(url_for(".register")) return render_template("admin/login.html")
def register(): # Only allow access if logged in or no users are registered if current_user.is_anonymous() and User.select().count() > 0: return current_app.login_manager.unauthorized() return render_template("admin/register.html")