mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
validation token valid query checking
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
import { v4 as uuidv4, v5 } from 'uuid'
|
||||
import { v4 as uuidv4, v5, validate as validateuuid } from 'uuid'
|
||||
import type { Database } from 'better-sqlite3'
|
||||
|
||||
import logger from '../../../utils/logger'
|
||||
@@ -288,7 +288,7 @@ function setup(data: SubmoduleData): Submodule {
|
||||
const user: User = req.session.user
|
||||
const { token, userid } = req.query
|
||||
|
||||
if (token && userid) {
|
||||
if (validateuuid(token) && !Number.isNaN(+userid)) {
|
||||
const specifiedUser: User = dbtools.Select(userDB, 'users', {
|
||||
id: +userid,
|
||||
})[0]
|
||||
@@ -305,6 +305,9 @@ function setup(data: SubmoduleData): Submodule {
|
||||
res.json({
|
||||
result: 'success',
|
||||
key: key,
|
||||
...((token || userid) && {
|
||||
msg: 'userid or token was provided, but was invalid',
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user