fix: 🐛 Add error notification if adding token to daemon fails (#2127)
✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12488
This commit is contained in:
1 parent
056008e13e
commit
f8b5dcd824
2 files changed
+7
-3
No files matched your search
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user