mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 07:25:19 +02:00
replace getToken with decode
This commit is contained in:
parent
666396384d
commit
9ebc9face6
1 changed files with 6 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
import cookieParser from 'cookie-parser'
|
||||
import { getToken } from 'next-auth/jwt'
|
||||
import { decode } from 'next-auth/jwt'
|
||||
|
||||
const SECRET = process.env.NEXTAUTH_SECRET
|
||||
const SECRET = process.env.NEXTAUTH_SECRET ?? 'REPLACE_THIS'
|
||||
|
||||
export const validateAuthJwt = async (req, res, next) => {
|
||||
cookieParser(SECRET)(req, res, async (err) => {
|
||||
|
@ -11,7 +11,10 @@ export const validateAuthJwt = async (req, res, next) => {
|
|||
|
||||
if (req.cookies && 'next-auth.session-token' in req.cookies) {
|
||||
try {
|
||||
const token = await getToken({ req, secret: SECRET })
|
||||
const token = await decode({
|
||||
token: req.cookies['next-auth.session-token'],
|
||||
secret: SECRET,
|
||||
})
|
||||
|
||||
if (token) {
|
||||
req.user = token
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue