Skip to content

Commit

Permalink
Convert clearSession to promise
Browse files Browse the repository at this point in the history
Added iOS platform check to method
  • Loading branch information
cocojoe committed Aug 14, 2017
1 parent 4e7941b commit 4c6cb1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ios/A0Auth0.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {

- (void)safariViewController:(SFSafariViewController *)controller didCompleteInitialLoad:(BOOL)didLoadSuccessfully {
if (self.didLoadCallback) {
didLoadSuccessfully ? self.didLoadCallback(@[[NSNull null]]) : self.didLoadCallback(@[@{@"error": @"failed to clear session"}]);
didLoadSuccessfully ? self.didLoadCallback(@[[NSNull null]]) : self.didLoadCallback(@[@{@"error": @"failed to load"}]);
self.didLoadCallback = nil;
} else if (!didLoadSuccessfully) {
NSDictionary *error = @{
Expand Down
12 changes: 9 additions & 3 deletions webauth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,20 @@ export default class WebAuth {
*
* @param {Object} parameters parameters to send
* @param {Bool} [parameters.federated] Optionally remove the IdP session.
* @returns {Callback}
* @returns {Promise}
* @see https://auth0.com/docs/logout
*
* @memberof WebAuth
*/
clearSession(options = {}, callback) {
clearSession(options = {}) {
const { clientId, domain, client, agent } = this;
const federated = options.federated || false;
A0Auth0.clearSession(domain, federated, callback);
return new Promise(function (resolve, reject) {
if (Platform.OS !== 'ios') { reject(new Error('clearSession only supported in iOS')); }
A0Auth0.clearSession(domain, federated, function (err, data) {
if (err !== null) return reject(err);
resolve();
});
});
}
}

0 comments on commit 4c6cb1a

Please sign in to comment.