Skip to content

Commit

Permalink
Add and expose detected users array to Node-RED context
Browse files Browse the repository at this point in the history
  • Loading branch information
cgjgh committed Aug 8, 2024
1 parent 8f7a96c commit 048936d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions nodes/config/ui_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,23 @@ module.exports = function (RED) {

// Assign allowed pages or null if not found
allowedPages = user?.allowedPages ?? null

// Add userId and last detected to global.store.detectedUsers
if (userId) {
// eslint-disable-next-line prefer-const
const currentTime = Math.floor(Date.now() / 1000)

// get detectedUsers from store
let detectedUsers = store?.detectedUsers || {}

if (!detectedUsers) {
detectedUsers = {}
}
detectedUsers[userId] = { userId, lastDetected: currentTime }

// update the global store
node.context().global.set('store.detectedUsers', detectedUsers)
}
}

// Initialize userPages based on filter disabled or zeroTrust value - start with empty map for zero trust
Expand Down

0 comments on commit 048936d

Please sign in to comment.