realms-wiki/realms/modules/auth/views.py

29 lines
823 B
Python
Raw Normal View History

from __future__ import absolute_import
from flask import current_app, render_template, request, redirect, Blueprint, flash, url_for, session
from flask_login import logout_user
2016-08-20 20:37:22 +03:00
from .models import Auth
2013-12-03 22:09:57 +02:00
blueprint = Blueprint('auth', __name__, template_folder='templates')
2013-12-03 22:09:57 +02:00
2014-08-30 18:06:12 +03:00
@blueprint.route("/login", methods=['GET', 'POST'])
2014-08-20 18:28:25 +03:00
def login():
next_url = request.args.get('next') or url_for(current_app.config['ROOT_ENDPOINT'])
session['next_url'] = next_url
2015-10-14 06:52:30 +03:00
return render_template("auth/login.html", forms=Auth.login_forms())
2014-08-30 18:06:12 +03:00
2015-10-14 06:52:30 +03:00
@blueprint.route("/logout")
def logout():
logout_user()
flash("You are now logged out")
return redirect(url_for(current_app.config['ROOT_ENDPOINT']))
2014-08-30 18:06:12 +03:00
@blueprint.route("/settings", methods=['GET', 'POST'])
def settings():
return render_template("auth/settings.html")