From 453ca63455fccb25d54a0c47799c31c1c57c3448 Mon Sep 17 00:00:00 2001 From: TemuulenBM Date: Thu, 4 Jan 2024 18:00:53 +0800 Subject: [PATCH 1/3] added function that checks 2fa --- addon/authenticators/fleetbase.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addon/authenticators/fleetbase.js b/addon/authenticators/fleetbase.js index 4b8a50b..98bd5b4 100644 --- a/addon/authenticators/fleetbase.js +++ b/addon/authenticators/fleetbase.js @@ -59,6 +59,12 @@ export default class FleetbaseAuthenticator extends Base { }); } + checkForTwoFactor(identity) { + return this.fetch.get('two-fa/check', { identity }).catch((error) => { + throw new Error(error.message); + }); + } + /** * Invalidates the current session * From 51ffe77b8c0072e6128103f64449abc2bb503cfc Mon Sep 17 00:00:00 2001 From: TemuulenBM Date: Fri, 5 Jan 2024 18:03:47 +0800 Subject: [PATCH 2/3] managed check2fa session --- addon/authenticators/fleetbase.js | 6 ------ addon/services/session.js | 13 +++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/addon/authenticators/fleetbase.js b/addon/authenticators/fleetbase.js index 98bd5b4..4b8a50b 100644 --- a/addon/authenticators/fleetbase.js +++ b/addon/authenticators/fleetbase.js @@ -59,12 +59,6 @@ export default class FleetbaseAuthenticator extends Base { }); } - checkForTwoFactor(identity) { - return this.fetch.get('two-fa/check', { identity }).catch((error) => { - throw new Error(error.message); - }); - } - /** * Invalidates the current session * 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); + }); + } } From 4282fa8828d77afacf7ee1f606b65bc74ce7d104 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Tue, 16 Jan 2024 18:19:35 +0800 Subject: [PATCH 3/3] minor patch on application adapter --- addon/adapters/application.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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;