prevent infinite loop with an invalid token

stable
juanfran 2016-11-03 10:22:00 +01:00
parent d19c431f16
commit d6c26087d8
2 changed files with 12 additions and 4 deletions

View File

@ -529,7 +529,10 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven
.search("force_next", search.force_next)
else
$location.url($navUrls.resolve("login"))
.search("next", nextUrl)
.search({
"unauthorized": true
"next": nextUrl
})
return $q.reject(response)

View File

@ -32,10 +32,11 @@ class LoginPage
'tgCurrentUserService',
'$location',
'$tgNavUrls',
'$routeParams'
'$routeParams',
'$tgAuth'
]
constructor: (currentUserService, $location, $navUrls, $routeParams) ->
constructor: (currentUserService, $location, $navUrls, $routeParams, $auth) ->
if currentUserService.isAuthenticated()
if not $routeParams['force_login']
url = $navUrls.resolve("home")
@ -43,7 +44,11 @@ class LoginPage
url = decodeURIComponent($routeParams['next'])
$location.search('next', null)
$location.url(url)
if $routeParams['unauthorized']
$auth.clear()
$auth.removeToken()
else
$location.url(url)
module.controller('LoginPage', LoginPage)