Skip to content

Commit

Permalink
Login: Correct auth for socketio
Browse files Browse the repository at this point in the history
  • Loading branch information
stephendade committed Jan 6, 2025
1 parent 539a52d commit 8219b50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,16 @@ app.post('/api/removeudpoutput', authenticateToken, [check('removeoutputIP').isI
res.send(JSON.stringify({ UDPoutputs: newOutput }))
})

io.on('connection', authenticateToken, function () {
io.engine.use((req, res, next) => {
const isHandshake = req._query.sid === undefined
if (isHandshake) {
authenticateToken(req, res, next)
} else {
next()
}
})

io.on('connection', function () {
// only set interval if not already set
if (FCStatusLoop !== null) {
return
Expand Down
6 changes: 5 additions & 1 deletion src/basePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ class basePage extends Component {


if (this.state.usedSocketIO) {
this.socket = io();
this.socket = io({
extraHeaders: {
authorization: `Bearer ${this.state.token}`
}
})

// Socket.io client
this.socket.on('disconnect', function () {
Expand Down

0 comments on commit 8219b50

Please sign in to comment.