diff --git a/addon/adapters/application.js b/addon/adapters/application.js index 80cc93f..352ddf1 100644 --- a/addon/adapters/application.js +++ b/addon/adapters/application.js @@ -95,7 +95,9 @@ export default class ApplicationAdapter extends RESTAdapter { const localStorageSession = JSON.parse(window.localStorage.getItem('ember_simple_auth-session')); if (localStorageSession) { const { authenticated } = localStorageSession; - token = authenticated.token; + if (authenticated) { + token = authenticated.token; + } // Check isAuthenticated again isAuthenticated = !!token; diff --git a/addon/services/session.js b/addon/services/session.js index 4cda6dd..745c0d1 100644 --- a/addon/services/session.js +++ b/addon/services/session.js @@ -218,4 +218,17 @@ export default class SessionService extends SimpleAuthSessionService { return Math.round((now - date) / 1000); } + + /** + * Checks for the presence of two-factor authentication for a given user identity. + * + * @param {String} identity + * @return {Promise} + * @throws {Error} + */ + checkForTwoFactor(identity) { + return this.fetch.get('two-fa/check', { identity }).catch((error) => { + throw new Error(error.message); + }); + } }