1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-14 10:53:30 +02:00
Mailu/core/admin/mailu/sso/views/base.py

30 lines
906 B
Python

from mailu import models
from mailu.sso import sso, forms
from flask import current_app as app
import flask
import flask_login
@sso.route('/login', methods=['GET', 'POST'])
def login():
form = forms.LoginForm()
if form.validate_on_submit():
user = models.User.login(form.email.data, form.pw.data)
if user:
flask.session.regenerate()
flask_login.login_user(user)
endpoint = flask.request.args.get('next', 'ui.index')
return flask.redirect(flask.url_for(endpoint)
or flask.url_for('ui.index'))
else:
flask.flash('Wrong e-mail or password', 'error')
return flask.render_template('login.html', form=form)
"""
@ui.route('/logout', methods=['GET'])
@access.authenticated
def logout():
flask_login.logout_user()
flask.session.destroy()
return flask.redirect(flask.url_for('.index'))
"""