mirror of
https://github.com/LukeHagar/idn-admin-console.git
synced 2025-12-09 20:47:46 +00:00
Refactor session handling and add logging
This commit is contained in:
@@ -7,34 +7,32 @@ export const actions = {
|
|||||||
const data = await request.formData();
|
const data = await request.formData();
|
||||||
|
|
||||||
const baseUrl = data.get('baseUrl');
|
const baseUrl = data.get('baseUrl');
|
||||||
const tenant = data.get('tenant');
|
|
||||||
const tenantUrl = data.get('tenantUrl');
|
const tenantUrl = data.get('tenantUrl');
|
||||||
|
|
||||||
if (!baseUrl || !tenantUrl) {
|
if (!baseUrl || !tenantUrl) {
|
||||||
redirect(302, '/login');
|
redirect(302, '/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionString = cookies.get('idnSession');
|
const session = { baseUrl: baseUrl.toString(), tenantUrl: tenantUrl.toString() };
|
||||||
|
console.log('session', session);
|
||||||
|
|
||||||
if (sessionString) {
|
const idnSessionString = cookies.get('idnSession');
|
||||||
|
|
||||||
|
if (idnSessionString) {
|
||||||
// console.log('sessionString', sessionString);
|
// console.log('sessionString', sessionString);
|
||||||
|
|
||||||
const session = JSON.parse(sessionString);
|
const idnSession = JSON.parse(idnSessionString);
|
||||||
if (session.org == tenant) {
|
if (idnSession && session.baseUrl.toLowerCase().includes(idnSession.org.toLowerCase())) {
|
||||||
// console.debug('Credential Cache Hit');
|
console.log('Credential Cache Hit');
|
||||||
redirect(302, '/home');
|
redirect(302, '/home');
|
||||||
} else {
|
} else {
|
||||||
// console.debug('Credential Cache Miss');
|
console.log('Credential Cache Miss');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @migration task: add path argument */ cookies.set(
|
cookies.set('session', JSON.stringify(session), {
|
||||||
'session',
|
path: '/'
|
||||||
JSON.stringify({ baseUrl, tenantUrl }),
|
});
|
||||||
{
|
|
||||||
path: '/'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
redirect(302, generateAuthLink(tenantUrl.toString()));
|
redirect(302, generateAuthLink(tenantUrl.toString()));
|
||||||
}
|
}
|
||||||
} satisfies Actions;
|
} satisfies Actions;
|
||||||
|
|||||||
Reference in New Issue
Block a user