mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-08 23:15:24 +02:00
Always use secure token
This commit is contained in:
parent
fea3985e24
commit
94f1acdd07
2 changed files with 3 additions and 6 deletions
|
@ -85,6 +85,7 @@ export const authOptions = {
|
|||
strategy: 'jwt' as SessionStrategy,
|
||||
maxAge: 1 * 24 * 60 * 60, // 1 Day
|
||||
},
|
||||
useSecureCookies: true,
|
||||
providers: [
|
||||
CredentialsProvider({
|
||||
name: 'Credentials',
|
||||
|
|
|
@ -8,14 +8,10 @@ export const validateAuthJwt = async (req, res, next) => {
|
|||
return res.status(500).json({ message: 'Internal Server Error' })
|
||||
}
|
||||
|
||||
const cookieName = req.secure
|
||||
? '__Secure-next-auth.session-token'
|
||||
: 'next-auth.session-token'
|
||||
|
||||
if (req.cookies && cookieName in req.cookies) {
|
||||
if (req.cookies && '__Secure-next-auth.session-token' in req.cookies) {
|
||||
try {
|
||||
const token = await decode({
|
||||
token: req.cookies[cookieName],
|
||||
token: req.cookies['__Secure-next-auth.session-token'],
|
||||
secret: SECRET,
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue