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

19 lines
615 B
Python
Raw Normal View History

2015-10-15 01:36:22 +03:00
from flask import current_app, request, redirect, Blueprint, flash, url_for
from ..ldap.models import User
from flask_ldap_login import LDAPLoginForm
blueprint = Blueprint('auth.ldap', __name__)
@blueprint.route("/login/ldap", methods=['POST'])
def login():
form = LDAPLoginForm()
if not form.validate():
flash('Form invalid', 'warning')
return redirect(url_for('auth.login'))
2015-10-15 23:55:38 +03:00
if User.auth(form.user, request.form['password']):
2015-10-15 01:36:22 +03:00
return redirect(request.args.get("next") or url_for(current_app.config['ROOT_ENDPOINT']))
else:
return redirect(url_for('auth.login'))