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 Meta:
csrf = False
target = fields.SelectField( u'Go to' )
email = fields.StringField(_('E-mail'), [validators.Email()])
pw = fields.PasswordField(_('Password'), [validators.DataRequired()])
submit = fields.SubmitField(_('Sign in'))

@ -1,55 +1,83 @@
{% import "macros.html" as macros %}
{% import "bootstrap/utils.html" as utils %}
{%- import "macros.html" as macros %}
{%- import "bootstrap/utils.html" as utils %}
<!doctype html>
<html>
<html lang="{{ session['language'] }}" data-static="{{ url_for('.static', filename='') }}">
<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='app.css') }}">
<title>Mailu - {{ config["SITENAME"] }}</title>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
<ul class="navbar-nav">
<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>
</ul>
</nav>
<aside class="main-sidebar sidebar-dark-primary">
<a class="brand-link">
<span class="brand-text font-weight-light">{{ config["SITENAME"] }}</span>
<aside class="main-sidebar sidebar-dark-primary nav-compact elevation-4">
<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>
</a>
{% block sidebar %}
{% include "sidebar_sso.html" %}
{% endblock %}
{%- include "sidebar_sso.html" %}
</aside>
<div class="content-wrapper">
<div class="content-wrapper text-sm">
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<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>
</div>
<div class="col-sm-6">
{% block main_action %}
{% endblock %}
{%- block main_action %}{%- endblock %}
</div>
</div>
</div>
</section>
<div class="content">
{{ utils.flashed_messages(container=False) }}
{% block content %}{% endblock %}
{{ utils.flashed_messages(container=False, default_category='success') }}
{%- block content %}{%- endblock %}
</div>
</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://adminlte.io/themes/v3/index3.html">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>
Built with <i class="fa fa-heart text-danger" aria-hidden="true"></i><span class="sr-only">love</span>
using <a href="https://flask.palletsprojects.com/">Flask</a>
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>
</div>
<script src="{{ url_for('.static', filename='vendor.js') }}"></script>

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

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

@ -1,8 +1,15 @@
<div class="sidebar">
<nav class="mt-2">
<div class="sidebar text-sm">
<nav class="mt-2">
<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'] %}
<li class="nav-item">
<a href="{{ url_for('ui.client') }}" class="nav-link">
@ -10,20 +17,25 @@
<p class="text">{% trans %}Client setup{% endtrans %}</p>
</a>
</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">
<a href="https://mailu.io" target="_blank" class="nav-link">
<i class="nav-icon fa fa-life-ring"></i>
<p class="text">{% trans %}Help{% endtrans %}</p>
</a>
</li>
{% endif %}
{% if False %}
<!-- Domain self-registration is only available when
</li>
{#
Domain self-registration is only available when
- Admin is available
- Domain Self-registration is enabled
- The current user is not logged on
-->
{% endif %}
- The current user is not logged on
#}
{% if config['DOMAIN_REGISTRATION'] %}
{% if not current_user.is_authenticated %}
{% if config['ADMIN'] %}
@ -36,13 +48,12 @@
{% endif %}
{% endif %}
{% endif %}
{% if False %}
<!-- User self-registration is only available when
{#
User self-registration is only available when
- Admin is available
- Self-registration is enabled
- The current user is not logged on
-->
{% endif %}
- The current user is not logged on
#}
{% if not current_user.is_authenticated %}
{% if signup_domains %}
{% if config['ADMIN'] %}

@ -10,12 +10,22 @@ import flask_login
def login():
form = forms.LoginForm()
endpoint = flask.request.args.get('next', 'ui.index')
if endpoint == 'ui.webmail':
endpoint = 'ui.webmail'
else:
endpoint = 'ui.index'
if str(app.config['WEBMAIL']).upper != 'NONE' and str(app.config['ADMIN']).upper != 'NONE' and endpoint != 'ui.webmail':
form.target.choices = [('Configuration page', 'Configuration page'), ('Webmail', 'Webmail')]
elif str(app.config['WEBMAIL']).upper != 'NONE' and str(app.config['ADMIN']).upper != 'NONE' and endpoint == 'ui.webmail':
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.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)
if user:
flask.session.regenerate()

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

Loading…
Cancel
Save