diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 89f69274..3385474a 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -136,10 +136,11 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, tgLoade $httpProvider.defaults.headers.get = {} # Add next param when user try to access to a secction need auth permissions. - authHttpIntercept = ($q, $location, $confirm, $navUrls) -> + authHttpIntercept = ($q, $location, $confirm, $navUrls, $lightboxService) -> return (promise) -> return promise.then null, (response) -> if response.status == 0 + $lightboxService.closeAll() $location.path($navUrls.resolve("error")) $location.replace() else if response.status == 401 @@ -147,7 +148,7 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, tgLoade $location.url($navUrls.resolve("login")).search("next=#{nextPath}") return $q.reject(response) - $provide.factory("authHttpIntercept", ["$q", "$location", "$tgConfirm", "$tgNavUrls", authHttpIntercept]) + $provide.factory("authHttpIntercept", ["$q", "$location", "$tgConfirm", "$tgNavUrls", "lightboxService", authHttpIntercept]) $httpProvider.responseInterceptors.push('authHttpIntercept') $httpProvider.interceptors.push('loaderInterceptor') diff --git a/app/coffee/modules/common/lightboxes.coffee b/app/coffee/modules/common/lightboxes.coffee index 31b36be3..019e91f4 100644 --- a/app/coffee/modules/common/lightboxes.coffee +++ b/app/coffee/modules/common/lightboxes.coffee @@ -49,6 +49,12 @@ class LightboxService extends taiga.Service $el.removeClass("open") + closeAll: -> + docEl = angular.element(document) + for lightboxEl in docEl.find(".lightbox.open") + @.close($(lightboxEl)) + + module.service("lightboxService", LightboxService)