Commit c402d148 authored by Jochen Kressin's avatar Jochen Kressin
Browse files

handle redirect after login correctly, for shared dashboard and vis links, fixes SGCS-46

parent a2c06ce7
......@@ -38,7 +38,8 @@ export default function (pluginRoot, server, APP_ROOT, API_ROOT) {
if (request.url.path.indexOf(API_ROOT) === 0 || request.method !== 'get') {
return reply(Boom.forbidden(error));
} else {
return reply.redirect(`${basePath}${APP_ROOT}/login`);
const nextUrl = encodeURIComponent(request.path);
return reply.redirect(`${basePath}${APP_ROOT}/login?nextUrl=${nextUrl}`);
}
}
reply.continue({credentials});
......
......@@ -14,6 +14,7 @@
<input type="text" class="form-control kuiTextInput" id="username" name="username" placeholder="Username"
ng-model="ui.credentials.username" required/>
</div>
<hr class="guideBreak">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-lock"></i></div>
<input type="password" class="form-control kuiTextInput" id="password" name="password" placeholder="Password"
......
......@@ -46,14 +46,12 @@ export default function LoginController(kbnUrl, $scope, $http, $window) {
const {query, hash} = parse($window.location.href, true);
let nextUrl;
if (query.next) {
nextUrl = query.next + (hash || '')
if (query.nextUrl) {
nextUrl = ROOT + query.nextUrl + (hash || '')
} else {
nextUrl = "/";
}
this.logintitle = hash;
this.submit = () => {
$http.post(`${API_ROOT}/login`, this.credentials)
.then(
......@@ -65,7 +63,7 @@ export default function LoginController(kbnUrl, $scope, $http, $window) {
// matter, in the latter case we always have a tenant as fallback if
// user has no tenants configured and PRIVATE is disabled
if (!chrome.getInjected("multitenancy.enabled") || chrome.getInjected("multitenancy.tenants.enable_global")) {
$window.location.href = `/`;
$window.location.href = `${nextUrl}`;
} else {
// GLOBAL is disabled, check if we have at least one tenant to choose from
var allTenants = response.data.tenants;
......@@ -77,7 +75,7 @@ export default function LoginController(kbnUrl, $scope, $http, $window) {
if (allTenants == null || allTenants.length == 0 || _.isEmpty(allTenants)) {
this.errorMessage = 'No tenant available for this user, please contact your system administrator.';
} else {
$window.location.href = `/`;
$window.location.href = `${nextUrl}`;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment