This commit is contained in:
Andras Bacsai
2021-06-07 21:33:11 +02:00
committed by GitHub
parent 9c173d1de0
commit 31b3f58b2c
36 changed files with 1480 additions and 1999 deletions

View File

@@ -80,9 +80,10 @@ async function connectMongoDB() {
'repository.name': application.configuration.repository.name,
'repository.organization': application.configuration.repository.organization,
'repository.branch': application.configuration.repository.branch,
'publish.domain': application.configuration.publish.domain
}, {
...application.configuration
}, { upsert: true })
}, { upsert: true, new: true })
}
} catch (error) {
console.log(error)
@@ -90,12 +91,24 @@ async function connectMongoDB() {
})()
export async function handle({ request, render }) {
export async function handle({ request, resolve }) {
const { SECRETS_ENCRYPTION_KEY } = process.env;
const session = initializeSession(request.headers, {
secret: SECRETS_ENCRYPTION_KEY,
cookie: { path: '/' }
});
let session;
try {
session = initializeSession(request.headers, {
secret: SECRETS_ENCRYPTION_KEY,
cookie: { path: '/' }
});
} catch(error) {
return {
status: 302,
headers: {
'set-cookie': 'kit.session=deleted;path=/;expires=Wed, 21 Oct 2015 07:28:00 GMT',
location: '/'
}
};
}
request.locals.session = session;
if (session?.data?.coolToken) {
try {
@@ -105,7 +118,7 @@ export async function handle({ request, render }) {
request.locals.session.destroy = true;
}
}
const response = await render(request);
const response = await resolve(request);
if (!session['set-cookie']) {
if (!session?.data?.coolToken && !publicPages.includes(request.path)) {
return {