chekc for auth and set cookie better
This commit is contained in:
parent
74019e97a6
commit
73a6565326
8 changed files with 62 additions and 17 deletions
|
|
@ -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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue