mirror of
https://github.com/Mailu/Mailu.git
synced 2025-01-16 02:46:44 +02:00
Redirect to configured ENV VAR for Admin/Webmail, further simplify nginx config.
This commit is contained in:
parent
f1a60aa6ea
commit
bdcc183165
@ -1,3 +1,4 @@
|
||||
from werkzeug.utils import redirect
|
||||
from mailu import models
|
||||
from mailu.sso import sso, forms
|
||||
from mailu.ui import access
|
||||
@ -22,14 +23,16 @@ def login():
|
||||
if form.validate_on_submit():
|
||||
if str(form.target.data) == 'Admin':
|
||||
endpoint = 'ui.index'
|
||||
destination = app.config['WEB_ADMIN']
|
||||
elif str(form.target.data) == 'Webmail':
|
||||
endpoint = 'ui.webmail'
|
||||
destination = app.config['WEB_WEBMAIL']
|
||||
|
||||
user = models.User.login(form.email.data, form.pw.data)
|
||||
if user:
|
||||
flask.session.regenerate()
|
||||
flask_login.login_user(user)
|
||||
return flask.redirect(flask.url_for(endpoint))
|
||||
return flask.redirect(destination)
|
||||
else:
|
||||
flask.flash('Wrong e-mail or password', 'error')
|
||||
client_ip = flask.request.headers["X-Real-IP"] if 'X-Real-IP' in flask.request.headers else flask.request.remote_addr
|
||||
|
@ -183,21 +183,11 @@ http {
|
||||
|
||||
location @webmail_login {
|
||||
return 302 /sso/login?next=ui.webmail;
|
||||
}
|
||||
|
||||
location ^~ /ui/webmail {
|
||||
include /etc/nginx/proxy.conf;
|
||||
return 302 {{ WEB_WEBMAIL }};
|
||||
}
|
||||
}
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
{% if ADMIN == 'true' %}
|
||||
location ^~ /ui {
|
||||
include /etc/nginx/proxy.conf;
|
||||
rewrite ^/ui/(.*) {{ WEB_ADMIN }}/ui/$1 redirect;
|
||||
}
|
||||
|
||||
location {{ WEB_ADMIN }} {
|
||||
return 301 {{ WEB_ADMIN }}/ui;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user