Merge/Update with changes from master

master
Diman0 3 years ago
parent bf0aad9820
commit 9894b49cbd

@ -11,6 +11,8 @@ LOCALPART_REGEX = "^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`
class LoginForm(flask_wtf.FlaskForm): class LoginForm(flask_wtf.FlaskForm):
class Meta: class Meta:
csrf = False csrf = False
target = fields.SelectField( u'Go to' )
email = fields.StringField(_('E-mail'), [validators.Email()]) email = fields.StringField(_('E-mail'), [validators.Email()])
pw = fields.PasswordField(_('Password'), [validators.DataRequired()]) pw = fields.PasswordField(_('Password'), [validators.DataRequired()])
submit = fields.SubmitField(_('Sign in')) submit = fields.SubmitField(_('Sign in'))

@ -1,55 +1,83 @@
{% import "macros.html" as macros %} {%- import "macros.html" as macros %}
{% import "bootstrap/utils.html" as utils %} {%- import "bootstrap/utils.html" as utils %}
<!doctype html> <!doctype html>
<html> <html lang="{{ session['language'] }}" data-static="{{ url_for('.static', filename='') }}">
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="{% trans %}Admin page for{% endtrans %} {{ config["SITENAME"] }}">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Mailu-Admin | {{ config["SITENAME"] }}</title>
<link rel="stylesheet" href="{{ url_for('.static', filename='vendor.css') }}"> <link rel="stylesheet" href="{{ url_for('.static', filename='vendor.css') }}">
<link rel="stylesheet" href="{{ url_for('.static', filename='app.css') }}"> <link rel="stylesheet" href="{{ url_for('.static', filename='app.css') }}">
<title>Mailu - {{ config["SITENAME"] }}</title>
</head> </head>
<body class="hold-transition sidebar-mini layout-fixed"> <body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper"> <div class="wrapper">
<nav class="main-header navbar navbar-expand navbar-white navbar-light"> <nav class="main-header navbar navbar-expand navbar-white navbar-light">
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a> <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars" title="{% trans %}toggle sidebar{% endtrans %}" aria-expanded="false"></i><span class="sr-only">{% trans %}toggle sidebar{% endtrans %}</span></a>
</li>
<li class="nav-item">
{%- for page, url in path %}
{%- if loop.index > 1 %}
<i class="fas fa-greater-than text-xs text-gray" aria-hidden="true"></i>
{%- endif %}
{%- if url %}
<a class="nav-link d-inline-block" href="{{ url }}" role="button">{{ page }}</a>
{%- else %}
<span class="nav-link d-inline-block">{{ page }}</span>
{%- endif %}
{%- endfor %}
</li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link" data-toggle="dropdown" href="#" aria-expanded="false">
<i class="fas fa-language text-xl" aria-hidden="true" title="{% trans %}change language{% endtrans %}"></i><span class="sr-only">Language</span>
<span class="badge badge-primary navbar-badge">{{ session['language'] }}</span></a>
<div class="dropdown-menu dropdown-menu-right p-0" id="mailu-languages">
{%- for locale in config.translations.values() %}
<a class="dropdown-item{% if locale.language == session['language'] %} active{% endif %}" href="{{ url_for('ui.set_language', language=locale.language) }}">{{ locale.get_language_name().title() }}</a>
{%- endfor %}
</div>
</li> </li>
</ul> </ul>
</nav> </nav>
<aside class="main-sidebar sidebar-dark-primary"> <aside class="main-sidebar sidebar-dark-primary nav-compact elevation-4">
<a class="brand-link"> <a class="brand-link bg-mailu-logo"{% if config["LOGO_BACKGROUND"] %} style="background-color:{{ config["LOGO_BACKGROUND"] }}!important;"{% endif %}>
<img src="{{ config["LOGO_URL"] if config["LOGO_URL"] else url_for('.static', filename='mailu.png') }}" width="33" height="33" alt="Mailu" class="brand-image mailu-logo img-circle elevation-3">
<span class="brand-text font-weight-light">{{ config["SITENAME"] }}</span> <span class="brand-text font-weight-light">{{ config["SITENAME"] }}</span>
</a> </a>
{% block sidebar %} {%- include "sidebar_sso.html" %}
{% include "sidebar_sso.html" %}
{% endblock %}
</aside> </aside>
<div class="content-wrapper"> <div class="content-wrapper text-sm">
<section class="content-header"> <section class="content-header">
<div class="container-fluid"> <div class="container-fluid">
<div class="row mb-2"> <div class="row mb-2">
<div class="col-sm-6"> <div class="col-sm-6">
<h1 class="m-0">{% block title %}{% endblock %}</h1> <h1 class="m-0">{%- block title %}{%- endblock %}</h1>
<small>{% block subtitle %}{% endblock %}</small> <small>{% block subtitle %}{% endblock %}</small>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
{% block main_action %} {%- block main_action %}{%- endblock %}
{% endblock %}
</div> </div>
</div> </div>
</div> </div>
</section> </section>
<div class="content"> <div class="content">
{{ utils.flashed_messages(container=False) }} {{ utils.flashed_messages(container=False, default_category='success') }}
{% block content %}{% endblock %} {%- block content %}{%- endblock %}
</div> </div>
</div> </div>
<footer class="main-footer"> <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 Built with <i class="fa fa-heart text-danger" aria-hidden="true"></i><span class="sr-only">love</span>
<a class="white-text" href="https://adminlte.io/themes/v3/index3.html">AdminLTE</a> using <a href="https://flask.palletsprojects.com/">Flask</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> and <a href="https://adminlte.io/themes/v3/index3.html">AdminLTE</a>.
<span class="fa-pull-right">
<i class="fa fa-code-branch" aria-hidden="true"></i><span class="sr-only">fork</span>
on <a href="https://github.com/Mailu/Mailu">Github</a>
</span>
</footer> </footer>
</div> </div>
<script src="{{ url_for('.static', filename='vendor.js') }}"></script> <script src="{{ url_for('.static', filename='vendor.js') }}"></script>

@ -1,7 +1,7 @@
{% extends "base_sso.html" %} {%- extends "base_sso.html" %}
{% block content %} {%- block content %}
{% call macros.card() %} {%- call macros.card() %}
{{ macros.form(form) }} {{ macros.form(form) }}
{% endcall %} {%- endcall %}
{% endblock %} {%- endblock %}

@ -1,13 +1,13 @@
{% extends "form_sso.html" %} {%- extends "form_sso.html" %}
{% block title %} {%- block title %}
{% trans %}Sign in{% endtrans %} {% trans %}Sign in{% endtrans %}
{% endblock %} {%- endblock %}
{% block subtitle %} {%- block subtitle %}
{% if endpoint == 'ui.index' %} {%- if endpoint == 'ui.index' %}
{% trans %}to access the configuration page{% endtrans %} {% trans %}to access the configuration page{% endtrans %}
{% elif endpoint == 'ui.webmail' %} {%- elif endpoint == 'ui.webmail' %}
{% trans %}to access the webmail page{% endtrans %} {% trans %}to access the webmail page{% endtrans %}
{% endif %} {%- endif %}
{% endblock %} {%- endblock %}

@ -1,8 +1,15 @@
<div class="sidebar"> <div class="sidebar text-sm">
<nav class="mt-2"> <nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" role="menu"> <ul class="nav nav-pills nav-sidebar flex-column" role="menu">
<li class="nav-header text-uppercase text-primary" role="none">{% trans %}Go to{% endtrans %}</li>
{%- if config["WEBMAIL"] != "none" %}
<li class="nav-item" role="none">
<a href="{{ config["WEB_WEBMAIL"] }}" target="_blank" class="nav-link" role="menuitem">
<i class="nav-icon far fa-envelope"></i>
<p>{% trans %}Webmail{% endtrans %} <i class="fas fa-external-link-alt text-xs"></i></p>
</a>
</li>
{% endif %}
{% if config['ADMIN'] %} {% if config['ADMIN'] %}
<li class="nav-item"> <li class="nav-item">
<a href="{{ url_for('ui.client') }}" class="nav-link"> <a href="{{ url_for('ui.client') }}" class="nav-link">
@ -10,20 +17,25 @@
<p class="text">{% trans %}Client setup{% endtrans %}</p> <p class="text">{% trans %}Client setup{% endtrans %}</p>
</a> </a>
</li> </li>
{% endif %}
<li class="nav-item" role="none">
<a href="{{ config["WEBSITE"] }}" target="_blank" class="nav-link" role="menuitem" rel="noreferrer">
<i class="nav-icon fa fa-globe"></i>
<p>{% trans %}Website{% endtrans %} <i class="fas fa-external-link-alt text-xs"></i></p>
</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a href="https://mailu.io" target="_blank" class="nav-link"> <a href="https://mailu.io" target="_blank" class="nav-link">
<i class="nav-icon fa fa-life-ring"></i> <i class="nav-icon fa fa-life-ring"></i>
<p class="text">{% trans %}Help{% endtrans %}</p> <p class="text">{% trans %}Help{% endtrans %}</p>
</a> </a>
</li> </li>
{% endif %} {#
{% if False %} Domain self-registration is only available when
<!-- Domain self-registration is only available when
- Admin is available - Admin is available
- Domain Self-registration is enabled - Domain Self-registration is enabled
- The current user is not logged on - The current user is not logged on
--> #}
{% endif %}
{% if config['DOMAIN_REGISTRATION'] %} {% if config['DOMAIN_REGISTRATION'] %}
{% if not current_user.is_authenticated %} {% if not current_user.is_authenticated %}
{% if config['ADMIN'] %} {% if config['ADMIN'] %}
@ -36,13 +48,12 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if False %} {#
<!-- User self-registration is only available when User self-registration is only available when
- Admin is available - Admin is available
- Self-registration is enabled - Self-registration is enabled
- The current user is not logged on - The current user is not logged on
--> #}
{% endif %}
{% if not current_user.is_authenticated %} {% if not current_user.is_authenticated %}
{% if signup_domains %} {% if signup_domains %}
{% if config['ADMIN'] %} {% if config['ADMIN'] %}

@ -11,11 +11,21 @@ def login():
form = forms.LoginForm() form = forms.LoginForm()
endpoint = flask.request.args.get('next', 'ui.index') endpoint = flask.request.args.get('next', 'ui.index')
if endpoint == 'ui.webmail': if str(app.config['WEBMAIL']).upper != 'NONE' and str(app.config['ADMIN']).upper != 'NONE' and endpoint != 'ui.webmail':
endpoint = 'ui.webmail' form.target.choices = [('Configuration page', 'Configuration page'), ('Webmail', 'Webmail')]
else: elif str(app.config['WEBMAIL']).upper != 'NONE' and str(app.config['ADMIN']).upper != 'NONE' and endpoint == 'ui.webmail':
endpoint = 'ui.index' form.target.choices = [('Webmail', 'Webmail'), ('Configuration page', 'Configuration page')]
elif str(app.config['WEBMAIL']).upper != 'NONE' and str(app.config['ADMIN']).upper == 'NONE':
form.target.choices = [('Webmail', 'Webmail')]
elif str(app.config['WEBMAIL']).upper == 'NONE' and str(app.config['ADMIN']).upper != 'NONE':
form.target.choices = [('Configuration page', 'Configuration page')]
if form.validate_on_submit(): if form.validate_on_submit():
if form.target.data == 'Configuration page':
endpoint = 'ui.index'
elif form.target.data == 'webmail':
endpoint = 'ui.webmail'
user = models.User.login(form.email.data, form.pw.data) user = models.User.login(form.email.data, form.pw.data)
if user: if user:
flask.session.regenerate() flask.session.regenerate()

@ -138,8 +138,8 @@ http {
} }
location ^~ /ui { location ^~ /ui {
include /etc/nginx/proxy.conf; include /etc/nginx/proxy.conf;
#rewrite ^/sso/(.*) {{ WEB_ADMIN }}/$1 redirect; rewrite ^/ui/(.*) {{ WEB_ADMIN }}/ui/$1 redirect;
return 302 {{ WEB_ADMIN }}/ui/; #return 302 {{ WEB_ADMIN }}/ui/;
} }
location ^~ /sso { location ^~ /sso {
include /etc/nginx/proxy.conf; include /etc/nginx/proxy.conf;

Loading…
Cancel
Save