Skip to content

Commit 08a1065

Browse files
committed
Merge pull request #134 from moskeyombus/readme-update
adding loginCancelled documentation to README
2 parents 10914bf + 55aa851 commit 08a1065

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,19 @@ the configuration object (this is the requested URL, payload and parameters)
3030
of every HTTP 401 response is buffered and everytime it happens, the
3131
`event:auth-loginRequired` message is broadcasted from $rootScope.
3232

33-
The `authService` has only one method: `loginConfirmed()`.
34-
You are responsible to invoke this method after user logged in. You may optionally pass in
35-
a data argument to the loginConfirmed method which will be passed on to the loginConfirmed
33+
The `authService` has only 2 methods: `loginConfirmed()` and `loginCancelled()`.
34+
35+
You are responsible to invoke `loginConfirmed()` after user logs in. You may optionally pass in
36+
a data argument to this method which will be passed on to the loginConfirmed
3637
$broadcast. This may be useful, for example if you need to pass through details of the user
3738
that was logged in. The `authService` will then retry all the requests previously failed due
3839
to HTTP 401 response.
3940

41+
You are responsible to invoke `loginCancelled()` when authentication has been invalidated. You may optionally pass in
42+
a data argument to this method which will be passed on to the loginCancelled
43+
$broadcast. The `authService` will cancel all pending requests previously failed and buffered due
44+
to HTTP 401 response.
45+
4046
In the event that a requested resource returns an HTTP 403 response (i.e. the user is
4147
authenticated but not authorized to access the resource), the user's request is discarded and
4248
the `event:auth-forbidden` message is broadcast from $rootScope.
@@ -60,14 +66,19 @@ the `function(response) {do-something-with-response}` will fire,
6066
###Advanced use case:
6167

6268
####Sending data to listeners:
63-
You can supply additional data to observers across your application who are listening for `event:auth-loginConfirmed`:
69+
You can supply additional data to observers across your application who are listening for `event:auth-loginConfirmed` and `event:auth-loginCancelled`:
6470

6571
$scope.$on('event:auth-loginConfirmed', function(event, data){
6672
$rootScope.isLoggedin = true;
6773
$log.log(data)
6874
});
6975

70-
Use the `authService.loginConfirmed([data])` method to emit data with your login event.
76+
$scope.$on('event:auth-loginCancelled', function(event, data){
77+
$rootScope.isLoggedin = false;
78+
$log.log(data)
79+
});
80+
81+
Use the `authService.loginConfirmed([data])` and `authService.loginCancelled([data])` methods to emit data with your login and logout events.
7182

7283
####Updating [$http(config)](https://docs.angularjs.org/api/ng/service/$http):
7384
Successful login means that the previous request are ready to be fired again, however now that login has occurred certain aspects of the previous requests might need to be modified on the fly. This is particularly important in a token based authentication scheme where an authorization token should be added to the header.

0 commit comments

Comments
 (0)