mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-09-01 00:17:13 +00:00
Merge pull request #7349 from smpaz7467/fix/login-redirect-deeplink
[Web] redirect deep links to the matching login page
This commit is contained in:
@@ -3563,7 +3563,16 @@ function protect_route($allowed_roles = ['admin', 'domainadmin', 'user'], $redir
|
|||||||
if (isset($redirects['unauthenticated'])) {
|
if (isset($redirects['unauthenticated'])) {
|
||||||
header('Location: ' . $redirects['unauthenticated']);
|
header('Location: ' . $redirects['unauthenticated']);
|
||||||
} else {
|
} else {
|
||||||
header('Location: /');
|
// Send a deep link to the login page for its area instead of the user login at /,
|
||||||
|
// e.g. /admin/dashboard -> /admin rather than /
|
||||||
|
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
|
||||||
|
if (strpos($request_uri, '/admin/') === 0) {
|
||||||
|
header('Location: /admin');
|
||||||
|
} elseif (strpos($request_uri, '/domainadmin/') === 0) {
|
||||||
|
header('Location: /domainadmin');
|
||||||
|
} else {
|
||||||
|
header('Location: /');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user