(js) follow requested URL after authentication

pull/237/merge
Francis Lachapelle 2017-08-29 16:03:19 -04:00
parent ee7fdcba9f
commit a65e96bdb5
2 changed files with 6 additions and 12 deletions

2
NEWS
View File

@ -7,7 +7,7 @@ New features
- [web] register SOGo as a handler for the mailto scheme (#1223) - [web] register SOGo as a handler for the mailto scheme (#1223)
Enhancements Enhancements
- - [web] follow requested URL after user authentication
Bug fixes Bug fixes
- [core] yearly repeating events are not shown in web calendar (#4237) - [core] yearly repeating events are not shown in web calendar (#4237)

View File

@ -27,29 +27,23 @@
function Authentication() { function Authentication() {
function redirectUrl(username, domain) { function redirectUrl(username, domain) {
var userName, address, baseAddress, altBaseAddress, parts, hostpart, protocol, newAddress; var userName, address, baseAddress, parts, hostpart, protocol, newAddress;
userName = username; userName = username;
if (domain) if (domain)
userName += '@' + domain.value; userName += '@' + domain.value;
address = '' + window.location.href; address = '' + window.location.href;
baseAddress = ApplicationBaseURL + '/' + encodeURIComponent(userName); baseAddress = ApplicationBaseURL + encodeURIComponent(userName);
if (baseAddress[0] == '/') { if (baseAddress[0] == '/') {
parts = address.split('/'); parts = address.split('/');
hostpart = parts[2]; hostpart = parts[2];
protocol = parts[0]; protocol = parts[0];
baseAddress = protocol + '//' + hostpart + baseAddress; baseAddress = protocol + '//' + hostpart + baseAddress;
} }
parts = baseAddress.split('/'); if (address.startsWith(baseAddress) && !address.endsWith('/logoff'))
parts.splice(0, 3);
altBaseAddress = parts.join('/');
if ((address.startsWith(baseAddress) || address.startsWith(altBaseAddress)) &&
!address.endsWith('/logoff')) {
newAddress = address; newAddress = address;
} else
else {
newAddress = baseAddress; newAddress = baseAddress;
}
return newAddress; return newAddress;
} }
@ -124,7 +118,7 @@
} }
} }
else { else {
d.resolve(redirectUrl(username, domain)); d.resolve({ url: redirectUrl(username, domain) });
} }
} }
}, function(response) { }, function(response) {