fleet/ee/vulnerability-dashboard/api/helpers/broadcast-session-change.js
Eric b1945b2128
Add fleet-vulnerability-dashboard repo to ee/ folder (#17428)
Closes: https://github.com/fleetdm/confidential/issues/4057

Changes:
- Added the contents of the fleet-vulnerability-dashboard repo to
ee/vulnerability-dashboard
- Added a github workflow to deploy the vulnerability dashboard on
Heroku
- Added a github workflow to test changes to the vulnerability-dashboard
- Updated the website's custom configuration to enable
auto-approvals/review requests to files in the
ee/vulnerability-dashboard folder
2024-03-13 13:06:11 -05:00

45 lines
787 B
JavaScript

module.exports = {
friendlyName: 'Broadcast session change',
description: 'Broadcast a socket notification indicating a change in login status.',
inputs: {
req: {
type: 'ref',
required: true,
},
},
exits: {
success: {
description: 'All done.',
},
},
fn: async function ({ req }) {
// If there's no sessionID, we don't need to broadcase a message about the old session.
if(!req.sessionID) {
return;
}
let roomName = `session${_.deburr(req.sessionID)}`;
let messageText = `You have signed out or signed into a different session in another tab or window. Reload the page to refresh your session.`;
sails.sockets.broadcast(roomName, 'session', { notificationText: messageText }, req);
}
};