Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit b3bfa06

Browse files
committed
Resolved issues JamesRandall#17 and JamesRandall#22
1 parent 27335ad commit b3bfa06

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "AngularJS-OAuth2",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"homepage": "https://github.com/JamesRandall/AngularJS-OAuth2",
55
"authors": [
66
"James Randall"

dist/angularJsOAuth2.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107

108108
if (service.token !== null) {
109109
if (!parsedFromHash || previousState == service.token.state) {
110-
$rootScope.$broadcast('oauth2:authSuccess');
110+
$rootScope.$broadcast('oauth2:authSuccess', service.token);
111111
var oauthRedirectRoute = $window.sessionStorage.getItem('oauthRedirectRoute');
112112
if (oauthRedirectRoute && oauthRedirectRoute != "null") {
113113
$window.sessionStorage.setItem('oauthRedirectRoute', null);
@@ -210,9 +210,11 @@
210210
'client_id=' + encodeURIComponent(params.clientId) + '&' +
211211
'redirect_uri=' + encodeURIComponent(params.redirectUrl) + '&' +
212212
'response_type=' + encodeURIComponent(params.responseType) + '&' +
213-
'scope=' + encodeURIComponent(params.scope) + '&' +
214-
'nonce=' + encodeURIComponent(params.nonce) + '&' +
215-
'state=' + encodeURIComponent(params.state);
213+
'scope=' + encodeURIComponent(params.scope) + '&';
214+
if (params.nonce) {
215+
service.url += 'nonce=' + encodeURIComponent(params.nonce) + '&';
216+
}
217+
service.url += 'state=' + encodeURIComponent(params.state);
216218
service.signOutUrl = params.signOutUrl;
217219
service.signOutRedirectUrl = params.signOutRedirectUrl;
218220
service.state = params.state;
@@ -243,7 +245,8 @@
243245
signOutUrl: '@', // url on the authorization server for logging out. Local token is deleted even if no URL is given but that will leave user logged in against STS
244246
signOutAppendToken: '@', // defaults to 'false', set to 'true' to append the token to the sign out url
245247
signOutRedirectUrl: '@', // url to redirect to after sign out on the STS has completed
246-
nonce: '@' // nonce value, optional
248+
nonce: '@', // nonce value, optional. If unspecified or an empty string and autoGenerateNonce is true then a nonce will be auto-generated
249+
autoGenerateNonce: '=' // Should a nonce be autogenerated if not supplied. Optional and defaults to true.
247250
}
248251
};
249252

@@ -285,8 +288,13 @@
285288
scope.signOutRedirectUrl = scope.signOutRedirectUrl || '';
286289
scope.unauthorizedAccessUrl = scope.unauthorizedAccessUrl || '';
287290
scope.state = scope.state || generateState();
288-
scope.nonce = scope.nonce || generateState();
289-
291+
if (scope.autoGenerateNonce === undefined) {
292+
scope.autoGenerateNonce = true;
293+
}
294+
if (!scope.nonce && scope.autoGenerateNonce) {
295+
scope.nonce = generateState();
296+
}
297+
290298
compile();
291299

292300
endpoint.init(scope);

0 commit comments

Comments
 (0)