From f8b5dcd824d1aeaa27a3a8e52cac8a1852a6772d Mon Sep 17 00:00:00 2001 From: Zhihe Li Date: Mon, 5 Feb 2024 14:21:13 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Add=20error=20notificatio?= =?UTF-8?q?n=20if=20adding=20token=20to=20daemon=20fails=20(#2127)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12488 --- ui/desktop/app/routes/application.js | 4 +++- ui/desktop/app/services/session.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/desktop/app/routes/application.js b/ui/desktop/app/routes/application.js index 8a17576f8..5ea39ff85 100644 --- a/ui/desktop/app/routes/application.js +++ b/ui/desktop/app/routes/application.js @@ -8,6 +8,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { A } from '@ember/array'; import { getOwner } from '@ember/application'; +import { notifyError } from 'core/decorators/notify'; export default class ApplicationRoute extends Route { // =services @@ -29,6 +30,7 @@ export default class ApplicationRoute extends Route { * reported by the main process. If they differ, update the main process * clusterUrl so that the renderer's CSP can be rewritten to allow requests. */ + @notifyError(({ message }) => message, { catch: true }) async beforeModel() { this.intl.setLocale(['en-us']); await this.session.setup(); @@ -39,7 +41,7 @@ export default class ApplicationRoute extends Route { // Add token to client daemon after a successful authentication restoration if (this.session.isAuthenticated) { const sessionData = this.session.data?.authenticated; - this.ipc.invoke('addTokenToClientDaemon', { + await this.ipc.invoke('addTokenToClientDaemon', { tokenId: sessionData?.id, token: sessionData?.token, }); diff --git a/ui/desktop/app/services/session.js b/ui/desktop/app/services/session.js index f3cf17c1d..bedc8d6f7 100644 --- a/ui/desktop/app/services/session.js +++ b/ui/desktop/app/services/session.js @@ -5,6 +5,7 @@ import { inject as service } from '@ember/service'; import BaseSessionService from 'ember-simple-auth/services/session'; +import { notifyError } from 'core/decorators/notify'; export default class SessionService extends BaseSessionService { @service ipc; @@ -13,12 +14,13 @@ export default class SessionService extends BaseSessionService { * Extend ember simple auth's handleAuthentication method * so we can hook in and add the user's token to the client daemon */ - handleAuthentication() { + @notifyError(({ message }) => message, { catch: true }) + async handleAuthentication() { super.handleAuthentication(...arguments); if (this.session.isAuthenticated) { const sessionData = this.data?.authenticated; - this.ipc.invoke('addTokenToClientDaemon', { + await this.ipc.invoke('addTokenToClientDaemon', { tokenId: sessionData?.id, token: sessionData?.token, });