mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
use global jwtSetrategy
This commit is contained in:
parent
df039c824f
commit
24d7038191
@ -80,10 +80,18 @@ class TextRoomServer {
|
||||
return next(new Error(`auth:server_error`))
|
||||
}
|
||||
|
||||
if (session.invalid) {
|
||||
if (!session.valid) {
|
||||
console.error(`[${socket.id}] failed to validate session caused by invalid token`, session)
|
||||
|
||||
return next(new Error(`auth:token_invalid`))
|
||||
}
|
||||
|
||||
if(!session.user_id) {
|
||||
console.error(`[${socket.id}] failed to validate session caused by invalid session. (missing user_id)`, session)
|
||||
|
||||
return next(new Error(`auth:invalid_session`))
|
||||
}
|
||||
|
||||
const userData = await mainAPI.get(`/user/${session.user_id}/data`)
|
||||
.then((res) => {
|
||||
return res.data
|
||||
|
@ -5,7 +5,6 @@ import { Session } from "@models"
|
||||
export default {
|
||||
method: "POST",
|
||||
route: "/validate",
|
||||
middlewares: ["useJwtStrategy"],
|
||||
fn: async (req, res) => {
|
||||
const token = req.body.session
|
||||
|
||||
@ -14,7 +13,7 @@ export default {
|
||||
valid: true
|
||||
}
|
||||
|
||||
await jwt.verify(token, req.jwtStrategy.secretOrKey, async (err, decoded) => {
|
||||
await jwt.verify(token, global.jwtStrategy.secretOrKey, async (err, decoded) => {
|
||||
if (err) {
|
||||
result.valid = false
|
||||
result.error = err.message
|
||||
@ -22,6 +21,7 @@ export default {
|
||||
if (err.message === "jwt expired") {
|
||||
result.expired = true
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user