Initial implementation for standalone sso page
parent
7e86f5cb57
commit
9fac3d7ad3
@ -0,0 +1,6 @@
|
||||
from flask import Blueprint
|
||||
|
||||
|
||||
sso = Blueprint('sso', __name__, static_folder='static', template_folder='templates')
|
||||
|
||||
from mailu.sso.views import *
|
@ -0,0 +1,14 @@
|
||||
from wtforms import validators, fields, widgets
|
||||
from wtforms_components import fields as fields_
|
||||
from flask_babel import lazy_gettext as _
|
||||
|
||||
import flask_login
|
||||
import flask_wtf
|
||||
import re
|
||||
|
||||
class LoginForm(flask_wtf.FlaskForm):
|
||||
class Meta:
|
||||
csrf = False
|
||||
email = fields.StringField(_('E-mail'), [validators.Email()])
|
||||
pw = fields.PasswordField(_('Password'), [validators.DataRequired()])
|
||||
submit = fields.SubmitField(_('Sign in'))
|
@ -0,0 +1,51 @@
|
||||
{% import "macros.html" as macros %}
|
||||
{% import "bootstrap/utils.html" as utils %}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="{{ url_for('.static', filename='vendor.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('.static', filename='app.css') }}">
|
||||
<title>Mailu-login - {{ config["SITENAME"] }}</title>
|
||||
</head>
|
||||
<body class="hold-transition skin-blue sidebar-mini">
|
||||
<div class="wrapper">
|
||||
<header class="main-header">
|
||||
<div class="logo">
|
||||
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</a>
|
||||
|
||||
<a>
|
||||
<span class="logo-lg"></span>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<section class="content-header">
|
||||
<div class="pull-right">
|
||||
{% block main_action %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<h1>
|
||||
{% block title %}{% endblock %}
|
||||
<small>{% block subtitle %}{% endblock %}</small>
|
||||
</h1>
|
||||
</section>
|
||||
|
||||
<section class="content">
|
||||
{{ utils.flashed_messages(container=False) }}
|
||||
{% block content %}{% endblock %}
|
||||
</section>
|
||||
</div>
|
||||
<footer class="main-footer">
|
||||
Built with <i class="fa fa-heart"></i> using <a class="white-text" href="http://flask.pocoo.org/">Flask</a> and
|
||||
<a class="white-text" href="https://almsaeedstudio.com/preview">AdminLTE</a>
|
||||
<span class="pull-right"><i class="fa fa-code-fork"></i> on <a class="white-text" href="https://github.com/Mailu/Mailu">Github</a></a></span>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="{{ url_for('static', filename='vendor.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='app.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,7 @@
|
||||
{% extends "base_sso.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% call macros.box() %}
|
||||
{{ macros.form(form) }}
|
||||
{% endcall %}
|
||||
{% endblock %}
|
@ -0,0 +1,9 @@
|
||||
{% extends "form_sso.html" %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}Sign in{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block subtitle %}
|
||||
{% trans %}to access IF statement for switch text for loggin in what the administration tools{% endtrans %}
|
||||
{% endblock %}
|
@ -0,0 +1,3 @@
|
||||
__all__ = [
|
||||
'base', 'hello'
|
||||
]
|
@ -0,0 +1,30 @@
|
||||
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'))
|
||||
"""
|
@ -0,0 +1,6 @@
|
||||
from mailu.sso import sso
|
||||
from flask import current_app as app
|
||||
|
||||
@sso.route("/")
|
||||
def hello_world():
|
||||
return "<p>Hello, World!</p>"
|
@ -1,9 +0,0 @@
|
||||
{% extends "form.html" %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}Sign in{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block subtitle %}
|
||||
{% trans %}to access the administration tools{% endtrans %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue