mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 11:10:11 +08:00
feat: apply auth to container and cli client
This commit is contained in:
1 parent
030dc95e24
commit
0f53696f71
8 files changed
+64
-27
No files matched your search
@@ -1,26 +1,18 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import Command from '../../models/command.js'
|
||||
import Session from '../../models/session.js'
|
||||
import { verifySessionJWT } from '../../utils/auth.js'
|
||||
import CommandHandler from '../../game/commandHandler.js'
|
||||
|
||||
export async function newCommand(req, res) {
|
||||
console.log('new command:', req.body)
|
||||
const { token, command, pwd, output, error, ...additionalData } = req.body
|
||||
const { command, pwd, output, error, ...additionalData } = req.body
|
||||
|
||||
if (!command) {
|
||||
res.status(400).json({ message: 'command is required' })
|
||||
return
|
||||
}
|
||||
|
||||
let sessionId
|
||||
try {
|
||||
const decoded = await verifySessionJWT(token)
|
||||
sessionId = decoded.session_id
|
||||
} catch (err) {
|
||||
res.status(401).json({ message: 'token not valid' })
|
||||
return
|
||||
}
|
||||
const sessionId = req.user.session_id
|
||||
|
||||
const session = await Session.findById(sessionId)
|
||||
|
||||
|
||||
Reference in new issue
Block a user