done
This commit is contained in:
@@ -12,8 +12,19 @@ async function authRoutes(fastify, options) {
|
||||
if (valid) {
|
||||
const token = config.get('authToken');
|
||||
const expiry = config.get('tokenExpiry');
|
||||
if (token && !apiClient.isTokenExpired(expiry) && value === token) {
|
||||
return reply.redirect('/dashboard');
|
||||
if (token && !apiClient.isTokenExpired(expiry)) {
|
||||
if (value === token) {
|
||||
return reply.redirect('/dashboard');
|
||||
}
|
||||
const previousToken = config.get('previousAuthToken');
|
||||
if (previousToken && value === previousToken) {
|
||||
const isHttps = (req.protocol === 'https') || ((req.headers['x-forwarded-proto'] || '').toString().toLowerCase() === 'https');
|
||||
reply.setCookie('kitchen_session', token, {
|
||||
signed: true, httpOnly: true, secure: isHttps,
|
||||
sameSite: 'strict', maxAge: 30 * 24 * 60 * 60, path: '/'
|
||||
});
|
||||
return reply.redirect('/dashboard');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,8 +41,19 @@ async function authRoutes(fastify, options) {
|
||||
if (valid) {
|
||||
const token = config.get('authToken');
|
||||
const expiry = config.get('tokenExpiry');
|
||||
if (token && !apiClient.isTokenExpired(expiry) && value === token) {
|
||||
return reply.redirect('/dashboard');
|
||||
if (token && !apiClient.isTokenExpired(expiry)) {
|
||||
if (value === token) {
|
||||
return reply.redirect('/dashboard');
|
||||
}
|
||||
const previousToken = config.get('previousAuthToken');
|
||||
if (previousToken && value === previousToken) {
|
||||
const isHttps = (req.protocol === 'https') || ((req.headers['x-forwarded-proto'] || '').toString().toLowerCase() === 'https');
|
||||
reply.setCookie('kitchen_session', token, {
|
||||
signed: true, httpOnly: true, secure: isHttps,
|
||||
sameSite: 'strict', maxAge: 30 * 24 * 60 * 60, path: '/'
|
||||
});
|
||||
return reply.redirect('/dashboard');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user