2016-07-09 06:39:11 +03:00
|
|
|
from flask import current_app, render_template, request, redirect, Blueprint, flash, url_for, session
|
2016-07-15 00:59:08 +03:00
|
|
|
from flask_login import logout_user
|
2015-10-14 06:52:30 +03:00
|
|
|
from realms.modules.auth.models import Auth
|
2013-12-03 22:09:57 +02:00
|
|
|
|
2016-08-16 06:06:05 +03: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():
|
2016-07-09 06:39:11 +03:00
|
|
|
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")
|