From 0bbef649b625051ea3d0e5bd3a62870574e45ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sat, 6 Jun 2015 22:43:41 +0200 Subject: [PATCH] Adding global error handler for ajax calls which run into redirections or unauthorized responses --- core/js/js.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/js/js.js b/core/js/js.js index 7604dc2a5b7e..5b696ca65f7a 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1084,6 +1084,12 @@ function initCore() { */ moment.locale(OC.getLocale()); + $( document ).ajaxError(function( event, request, settings ) { + if (_.contains([302, 307, 401], request.status)) { + var app = $('#content').attr('class').substring(4); + OC.redirect(OC.generateUrl('apps/' + app)); + } + }); /** * Calls the server periodically to ensure that session doesn't