chekc for auth and set cookie better

This commit is contained in:
counterweight 2025-02-13 13:14:42 +01:00
parent 74019e97a6
commit 73a6565326
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
8 changed files with 62 additions and 17 deletions

View file

@ -12,7 +12,7 @@ async function createSession(sessionUuid) {
const expiryTimestamp = new Date(currentTimestamp.getTime());
expiryTimestamp.setSeconds(expiryTimestamp.getSeconds() + constants.DEFAULT_SESSION_DURATION_SECONDS);
await SessionCreated.create({
return await SessionCreated.create({
uuid: sessionUuid,
created_at: currentTimestamp.toISOString(),
expires_at: expiryTimestamp.toISOString()
@ -55,8 +55,25 @@ async function relateSessionToPublicKey(sessionUuid, publicKey) {
});
}
async function isSessionAuthorized(sessionUuid) {
const isSessionRelatedToPublicKey = await SessionRelatedToPublickey.findOne(
{
where: {
session_uuid: sessionUuid
}
}
);
if (isSessionRelatedToPublicKey) {
return true;
}
return false;
}
module.exports = {
createSession,
isSessionValid,
relateSessionToPublicKey
relateSessionToPublicKey,
isSessionAuthorized
}