ignoreAuthModule: true makes httpBuffer empty
deepikakamboj opened this issue · 2 comments
I don't want the '/login' request to be fired again on loginConfirmed() but other requests in the buffer to be fired. So I used ignoreAuthModule: true in the login post. But this somehow makes buffer [] and so requests are made.
It works fine if login is successful the first time. But if I have provided wrong password, login returns 401, on reentering correct password, the other calls that should be made are not made.
$http({ignoreAuthModule: true, method: 'POST', url: '/s/login', data: loginData, headers: {'x-csrf-token': csrfToken}})
.success(function () {
console.log('success case');
$scope.busy = false;
angular.element('#loginModal').modal('hide');
authService.loginConfirmed();
})
.error(function (data, status) {
console.log('error case');
$scope.busy = false;
if (status === 401) {
$scope.error = 'Incorrect username and/or password!';
} else {
$scope.error = 'An error occurred: ' + (data || {}).reason;
}
authService.loginCancelled();
});
})
Understood the issue I was facing. The buffer was becoming empty because it first reached the error case and in loginCancelled(), the buffer is set to empty. Removed authService.loginCancelled() from my code in error scenario and it works fine now.
Hi, I am glad it all works for you. BTW: in the future, when you paste code snippets, use proper format tags, so the code is readable. See this:
$http({
ignoreAuthModule: true,
method: 'POST',
url: '/s/login',
data: loginData,
headers: {'x-csrf-token': csrfToken}
})
.success(function () {
console.log('success case');
$scope.busy = false;
angular.element('#loginModal').modal('hide');
authService.loginConfirmed();
})
[...]