From fa3704e69d6b80e38242c99617bf5609b1036843 Mon Sep 17 00:00:00 2001 From: Hernan Zalazar Date: Thu, 17 Aug 2017 20:30:57 -0300 Subject: [PATCH] Fix Platform check Improve error message and use AuthError type --- webauth/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webauth/index.js b/webauth/index.js index 3adf738c..eeff651a 100644 --- a/webauth/index.js +++ b/webauth/index.js @@ -109,10 +109,18 @@ export default class WebAuth { * @memberof WebAuth */ clearSession(options = {}) { + if (Platform.OS !== 'ios') { + return Promise.reject(new AuthError({ + json: { + error: 'a0.platform.not_available', + error_description: `Cannot perform operation in platform ${Platform.OS}` + }, + status: 0 + })); + } const { clientId, domain, client, agent } = this; const federated = options.federated || false; return new Promise(function (resolve, reject) { - if (Platform.OS !== 'ios') { reject(new Error('clearSession only supported in iOS')); } const logoutURL = `https://${domain}/v2/logout${federated ? '?federated' : ''}`; console.log(logoutURL); A0Auth0.didLoadURL(logoutURL, function (err, data) {