I cant understand, certain things in this code http://www.espeo.pl/2012/02/26/authentication-in-angularjs-application This code, this trying to resend same request(the one user requests before logging in) after the user logs in.
My question
-
function retry(req) {
$http(req.config).then(function(response) {
req.deferred.resolve(response);
});
}
Please have a look at the code in the above url for understanding how the retry method works.
You can resolve a promise with whatever you want. In this case, a promise was returned to the application when the 401 status code/error was first encountered. Now, after the loginConfirmed event, the request is sent again and the response is used to resolve that promise.