Files
threshold-ui/ui/desktop/app/services/session.js
T
hashicorp-copywrite[bot] 314c1b36f4 [COMPLIANCE] Add Copyright and License Headers (#2100)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2024-01-22 12:12:44 -05:00

28 lines
730 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { inject as service } from '@ember/service';
import BaseSessionService from 'ember-simple-auth/services/session';
export default class SessionService extends BaseSessionService {
@service ipc;
/**
* Extend ember simple auth's handleAuthentication method
* so we can hook in and add the user's token to the client daemon
*/
handleAuthentication() {
super.handleAuthentication(...arguments);
if (this.session.isAuthenticated) {
const sessionData = this.data?.authenticated;
this.ipc.invoke('addTokenToClientDaemon', {
tokenId: sessionData?.id,
token: sessionData?.token,
});
}
}
}