Commit 73a8847b authored by Jochen Kressin's avatar Jochen Kressin
Browse files

fixed NPE when no preferences cookie exists

parent 36971e52
......@@ -105,7 +105,6 @@ export default class SearchGuardBackend {
}
getTenantByPreference(request, username, tenants, globalEnabled, privateEnabled) {
// delete user from tenants first to check if we have a tenant to choose from at all
// keep original preferences untouched, we need the original values again
// http://stackoverflow.com/questions/728360/how-do-i-correctly-clone-a-javascript-object
......@@ -118,17 +117,19 @@ export default class SearchGuardBackend {
}
// get users preferred tenant
var prefs = request.state.searchguard_preferences;
var preferredTenant = prefs[username];
if (prefs) {
var preferredTenant = prefs[username];
// user has a preferred tenant, check if it is accessible
if (preferredTenant && tenants[preferredTenant]) {
return preferredTenant;
}
// user has a preferred tenant, check if it is accessible
if (preferredTenant && tenants[preferredTenant]) {
return preferredTenant;
}
// special case: in tenants returned from SG, the private tenant is
// the username of the logged in user, but the header value is __user__
if (preferredTenant == "__user__" && tenants[username] && privateEnabled) {
return "__user__";
// special case: in tenants returned from SG, the private tenant is
// the username of the logged in user, but the header value is __user__
if (preferredTenant == "__user__" && tenants[username] && privateEnabled) {
return "__user__";
}
}
// no preference, or tenant no accessible anymore, choose either global or private
......
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