Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
router.post('/token-refresh', function *(next) {
const token = this.request.body.token
try {
const decoded = jwt.verify(token, process.env.SESSION_SECRET)
} catch (err) {
this.status = 401
this.body = { error: err }
return
}
const query = User.where({ _id: decoded.username })
try {
var user = yield query.findOne()
} catch (err) {
log('Couldn\'t load user', err)
}
if (!user) {
router.post('/token-refresh', async (ctx, next) => {
const token = ctx.request.body.token
let decoded = false
try {
decoded = jwt.verify(token, process.env.SESSION_SECRET)
} catch (err) {
ctx.status = 401
ctx.body = { error: err }
return
}
const query = User.where({ _id: decoded.username })
let user = false
try {
user = await query.findOne()
} catch (err) {
log('Couldn\'t load user', err)
}
router.post('/token-refresh', function *(next) {
const token = this.request.body.token
let decoded = false
try {
decoded = jwt.verify(token, process.env.SESSION_SECRET)
} catch (err) {
this.status = 401
this.body = { error: err }
return
}
const query = User.where({ _id: decoded.username })
let user = false
try {
user = yield query.findOne()
} catch (err) {
log('Couldn\'t load user', err)
}