@@ -3,35 +3,41 @@ HTTP Auth Interceptor Module
33for AngularJS
44-------------
55
6- This is the implementation of the concept described in
7- [ Authentication in AngularJS (or similar) based application] ( http://www.espeo.pl/2012/02/26/authentication-in-angularjs-application ) .
6+ This is the implementation of the concept described in
7+ [ Authentication in AngularJS (or similar) based application] ( http://www.espeo.pl/2012/02/26/authentication-in-angularjs-application ) .
8+
9+ There are releases for both AngularJS ** 1.0.x** and ** 1.2.x** ,
10+ see [ releases] ( https://github.com/witoldsz/angular-http-auth/releases ) .
811
912Launch demo [ here] ( http://witoldsz.github.com/angular-http-auth/ )
10- or switch to [ gh-pages] ( https://github.com/witoldsz/angular-http-auth/tree/gh-pages )
13+ or switch to [ gh-pages] ( https://github.com/witoldsz/angular-http-auth/tree/gh-pages )
1114branch for source code of the demo.
1215
1316Manual
1417------
1518
16- This module installs $http interceptor and provides the ' authService' .
19+ This module installs $http interceptor and provides the ` authService ` .
1720
1821The $http interceptor does the following:
19- the configuration object (this is the requested URL, payload and parameters)
20- of every HTTP 401 response is buffered and everytime it happens, the
21- ' event: auth-loginRequired ' message is broadcasted from $rootScope.
22+ the configuration object (this is the requested URL, payload and parameters)
23+ of every HTTP 401 response is buffered and everytime it happens, the
24+ ` event:auth-loginRequired ` message is broadcasted from $rootScope.
2225
23- The ' authService' has only one method: #loginConfirmed().
24- You are responsible to invoke this method after user logged in. You may optionally pass in
26+ The ` authService ` has only one method: #loginConfirmed().
27+ You are responsible to invoke this method after user logged in. You may optionally pass in
2528a data argument to the loginConfirmed method which will be passed on to the loginConfirmed
26- $broadcast. This may be useful, for example if you need to pass through details of the user
27- that was logged in. The ' authService' will then retry all the requests previously failed due
29+ $broadcast. This may be useful, for example if you need to pass through details of the user
30+ that was logged in. The ` authService ` will then retry all the requests previously failed due
2831to HTTP 401 response.
2932
3033###Typical use case:
3134
32- * somewhere the: ** $http(...).then(function(response) { do-something-with-response })** is invoked,
33- * the response of that requests is a HTTP 401,
34- * 'http-auth-interceptor' captures the initial request and broadcasts 'event: auth-loginRequired ',
35- * your application intercepts this to e.g. show a login dialog (or whatever else),
36- * once your application figures out the authentication is OK, you are to call: ** authService.loginConfirmed()** ,
37- * your initial failed request will now be retried and finally, the ** do-something-with-response** will fire.
35+ * somewhere (some service or controller) the: ` $http(...).then(function(response) { do-something-with-response }) ` is invoked,
36+ * the response of that requests is a ** HTTP 401** ,
37+ * ` http-auth-interceptor ` captures the initial request and broadcasts ` event:auth-loginRequired ` ,
38+ * your application intercepts this to e.g. show a login dialog:
39+ * DO NOT REDIRECT anywhere (you can hide your forms), just show login dialog
40+ * once your application figures out the authentication is OK, call: ` authService.loginConfirmed() ` ,
41+ * your initial failed request will now be retried and when proper response is finally received,
42+ the ` function(response) {do-something-with-response} ` will fire,
43+ * your application will continue as nothing had happened.
0 commit comments