diff --git a/NEWS b/NEWS
index b34a8f3b6..8c2d6415e 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Enhancements
Bug fixes
- [core] properly update the last-modified attribute (#4313)
- [web] prevent deletion of special folders using del key
+ - [web] fixed SAML2 session timeout handling during XHR requests
- [eas] improved alarms syncing with EAS devices (#4351)
- [eas] avoid potential cache update when breaking sync queries (#4422)
diff --git a/UI/Common/UIxPageFrame.m b/UI/Common/UIxPageFrame.m
index cbfbd1dbe..9e46bda52 100644
--- a/UI/Common/UIxPageFrame.m
+++ b/UI/Common/UIxPageFrame.m
@@ -472,6 +472,15 @@
return [[sd authenticationType] isEqualToString: @"cas"];
}
+- (BOOL) usesSAML2Authentication
+{
+ SOGoSystemDefaults *sd;
+
+ sd = [SOGoSystemDefaults sharedSystemDefaults];
+
+ return [[sd authenticationType] isEqualToString: @"saml2"];
+}
+
- (NSString *) userIdentification
{
NSString *v;
diff --git a/UI/Templates/UIxPageFrame.wox b/UI/Templates/UIxPageFrame.wox
index dc4d9910c..489a02f92 100644
--- a/UI/Templates/UIxPageFrame.wox
+++ b/UI/Templates/UIxPageFrame.wox
@@ -85,6 +85,12 @@
var usesCASAuthentication = false;
+
+ var usesSAML2Authentication = true;
+
+
+ var usesSAML2Authentication = false;
+
var UserFolderURL = '';
var UserLogin = '';
diff --git a/UI/WebServerResources/js/Common/Common.app.js b/UI/WebServerResources/js/Common/Common.app.js
index 719720842..93c23f353 100644
--- a/UI/WebServerResources/js/Common/Common.app.js
+++ b/UI/WebServerResources/js/Common/Common.app.js
@@ -267,9 +267,10 @@
var deferred, iframe;
if (/^application\/json/.test(rejection.config.headers.Accept)) {
// Handle CAS ticket renewal
- if ($window.usesCASAuthentication && rejection.status == -1) {
+ if (($window.usesCASAuthentication && rejection.status == -1) ||
+ ($window.usesSAML2Authentication && rejection.status == 401)) {
deferred = $q.defer();
- iframe = angular.element('');
+ iframe = angular.element('');
iframe.on('load', function() {
// Once the browser has followed the redirection, send the initial request
var $http = $injector.get('$http');