Skip to content

Add responseType code and password with token refresh interval #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Disable refresh token only if server answered an error 40x
  • Loading branch information
babelouest committed Jun 30, 2018
commit aed81057e455fd9a1e6fcc616024496c9684442b
25 changes: 17 additions & 8 deletions app/scripts/services/access-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ accessTokenService.factory('AccessToken', ['Storage', '$rootScope', '$http', '$q
if (!!service.typedLogin && !!service.typedPassword) {
return reconnect();
} else {
if (error.status === 401 || error.status === 400) {
cancelExpiresAtEvent();
Storage.delete('token');
$rootScope.$broadcast('oauth:expired');
service.runExpired();
}
if (error.status === 401 || error.status === 400) {
cancelExpiresAtEvent();
Storage.delete('token');
$rootScope.$broadcast('oauth:expired');
service.runExpired();
}
}
});
} else {
Expand Down Expand Up @@ -241,8 +241,17 @@ accessTokenService.factory('AccessToken', ['Storage', '$rootScope', '$http', '$q
angular.extend(service.token, result.data);
setTokenInSession();
$rootScope.$broadcast('oauth:refresh', service.token);
}, function() {
$rootScope.$broadcast('oauth:denied');
}, function(error) {
if (!!service.typedLogin && !!service.typedPassword) {
return reconnect();
} else {
if (error.status === 401 || error.status === 400) {
cancelExpiresAtEvent();
Storage.delete('token');
$rootScope.$broadcast('oauth:expired');
service.runExpired();
}
}
});
};

Expand Down
27 changes: 18 additions & 9 deletions dist/oauth-ng.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* oauth-ng - v0.4.10 - 2018-03-02 */
/* oauth-ng - v0.4.10 - 2018-06-30 */

'use strict';

Expand Down Expand Up @@ -567,12 +567,12 @@ accessTokenService.factory('AccessToken', ['Storage', '$rootScope', '$http', '$q
if (!!service.typedLogin && !!service.typedPassword) {
return reconnect();
} else {
if (error.status === 401 || error.status === 400) {
cancelExpiresAtEvent();
Storage.delete('token');
$rootScope.$broadcast('oauth:expired');
service.runExpired();
}
if (error.status === 401 || error.status === 400) {
cancelExpiresAtEvent();
Storage.delete('token');
$rootScope.$broadcast('oauth:expired');
service.runExpired();
}
}
});
} else {
Expand Down Expand Up @@ -605,8 +605,17 @@ accessTokenService.factory('AccessToken', ['Storage', '$rootScope', '$http', '$q
angular.extend(service.token, result.data);
setTokenInSession();
$rootScope.$broadcast('oauth:refresh', service.token);
}, function() {
$rootScope.$broadcast('oauth:denied');
}, function(error) {
if (!!service.typedLogin && !!service.typedPassword) {
return reconnect();
} else {
if (error.status === 401 || error.status === 400) {
cancelExpiresAtEvent();
Storage.delete('token');
$rootScope.$broadcast('oauth:expired');
service.runExpired();
}
}
});
};

Expand Down