From b575f29e7a9e8920a9555c2576fe1adbb02119ce Mon Sep 17 00:00:00 2001 From: Witold Szczerba Date: Tue, 3 Dec 2013 11:12:28 +0100 Subject: [PATCH 1/2] docs: README.md updated --- README.md | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index eefd6ac..3b7e1a6 100644 --- a/README.md +++ b/README.md @@ -3,35 +3,41 @@ HTTP Auth Interceptor Module for AngularJS ------------- -This is the implementation of the concept described in -[Authentication in AngularJS (or similar) based application](http://www.espeo.pl/2012/02/26/authentication-in-angularjs-application). +This is the implementation of the concept described in +[Authentication in AngularJS (or similar) based application](http://www.espeo.pl/2012/02/26/authentication-in-angularjs-application). + +There are releases for both AngularJS **1.0.x** and **1.2.x**, +see [releases](https://github.com/witoldsz/angular-http-auth/releases). Launch demo [here](http://witoldsz.github.com/angular-http-auth/) -or switch to [gh-pages](https://github.com/witoldsz/angular-http-auth/tree/gh-pages) +or switch to [gh-pages](https://github.com/witoldsz/angular-http-auth/tree/gh-pages) branch for source code of the demo. Manual ------ -This module installs $http interceptor and provides the 'authService'. +This module installs $http interceptor and provides the `authService`. The $http interceptor does the following: -the configuration object (this is the requested URL, payload and parameters) -of every HTTP 401 response is buffered and everytime it happens, the -'event:auth-loginRequired' message is broadcasted from $rootScope. +the configuration object (this is the requested URL, payload and parameters) +of every HTTP 401 response is buffered and everytime it happens, the +`event:auth-loginRequired` message is broadcasted from $rootScope. -The 'authService' has only one method: #loginConfirmed(). -You are responsible to invoke this method after user logged in. You may optionally pass in +The `authService` has only one method: #loginConfirmed(). +You are responsible to invoke this method after user logged in. You may optionally pass in a data argument to the loginConfirmed method which will be passed on to the loginConfirmed -$broadcast. This may be useful, for example if you need to pass through details of the user -that was logged in. The 'authService' will then retry all the requests previously failed due +$broadcast. This may be useful, for example if you need to pass through details of the user +that was logged in. The `authService` will then retry all the requests previously failed due to HTTP 401 response. ###Typical use case: -* somewhere the: **$http(...).then(function(response) { do-something-with-response })** is invoked, -* the response of that requests is a HTTP 401, -* 'http-auth-interceptor' captures the initial request and broadcasts 'event:auth-loginRequired', -* your application intercepts this to e.g. show a login dialog (or whatever else), -* once your application figures out the authentication is OK, you are to call: **authService.loginConfirmed()**, -* your initial failed request will now be retried and finally, the **do-something-with-response** will fire. +* somewhere (some service or controller) the: `$http(...).then(function(response) { do-something-with-response })` is invoked, +* the response of that requests is a **HTTP 401**, +* `http-auth-interceptor` captures the initial request and broadcasts `event:auth-loginRequired`, +* your application intercepts this to e.g. show a login dialog: + * DO NOT REDIRECT anywhere (you can hide your forms), just show login dialog +* once your application figures out the authentication is OK, call: `authService.loginConfirmed()`, +* your initial failed request will now be retried and when proper response is finally received, +the `function(response) {do-something-with-response}` will fire, +* your application will continue as nothing had happened. From 95e9cc17414c28bccb48c4fcca9f65994a65bca6 Mon Sep 17 00:00:00 2001 From: Witold Szczerba Date: Thu, 12 Dec 2013 14:33:08 +0100 Subject: [PATCH 2/2] adjusting bower.json --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index a98cf2f..c693835 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "author": "Witold Szczerba", "name": "angular-http-auth", - "version": "0.1.0", + "version": "1.0.1", "homepage": "https://github.com/witoldsz/angular-http-auth", "repository": { "type": "git", @@ -9,6 +9,6 @@ }, "main": "./src/http-auth-interceptor.js", "dependencies": { - "angular": "1.0.6" + "angular": "^1.0" } }