mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 07:25:19 +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,
|
strategy: 'jwt' as SessionStrategy,
|
||||||
maxAge: 1 * 24 * 60 * 60, // 1 Day
|
maxAge: 1 * 24 * 60 * 60, // 1 Day
|
||||||
},
|
},
|
||||||
|
useSecureCookies: true,
|
||||||
providers: [
|
providers: [
|
||||||
CredentialsProvider({
|
CredentialsProvider({
|
||||||
name: 'Credentials',
|
name: 'Credentials',
|
||||||
|
|
|
@ -8,14 +8,10 @@ export const validateAuthJwt = async (req, res, next) => {
|
||||||
return res.status(500).json({ message: 'Internal Server Error' })
|
return res.status(500).json({ message: 'Internal Server Error' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const cookieName = req.secure
|
if (req.cookies && '__Secure-next-auth.session-token' in req.cookies) {
|
||||||
? '__Secure-next-auth.session-token'
|
|
||||||
: 'next-auth.session-token'
|
|
||||||
|
|
||||||
if (req.cookies && cookieName in req.cookies) {
|
|
||||||
try {
|
try {
|
||||||
const token = await decode({
|
const token = await decode({
|
||||||
token: req.cookies[cookieName],
|
token: req.cookies['__Secure-next-auth.session-token'],
|
||||||
secret: SECRET,
|
secret: SECRET,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue