wip sessionService
This commit is contained in:
parent
ba9b4d5ef3
commit
0f4ccf9847
1 changed files with 6 additions and 4 deletions
|
|
@ -5,12 +5,14 @@ const models = require('../models');
|
||||||
const constants = require('../constants');
|
const constants = require('../constants');
|
||||||
|
|
||||||
class SessionServiceProvider {
|
class SessionServiceProvider {
|
||||||
constructor({ invitesService }) {
|
constructor({ models, constants, invitesService }) {
|
||||||
|
this.models = models;
|
||||||
|
this.constants = constants;
|
||||||
this.invitesService = invitesService;
|
this.invitesService = invitesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
provide() {
|
provide() {
|
||||||
async function createSession(sessionUuid) {
|
const createSession = async (sessionUuid) => {
|
||||||
const currentTimestamp = new Date();
|
const currentTimestamp = new Date();
|
||||||
const expiryTimestamp = new Date(currentTimestamp.getTime());
|
const expiryTimestamp = new Date(currentTimestamp.getTime());
|
||||||
expiryTimestamp.setSeconds(
|
expiryTimestamp.setSeconds(
|
||||||
|
|
@ -18,12 +20,12 @@ class SessionServiceProvider {
|
||||||
constants.DEFAULT_SESSION_DURATION_SECONDS
|
constants.DEFAULT_SESSION_DURATION_SECONDS
|
||||||
);
|
);
|
||||||
|
|
||||||
return await models.SessionCreated.create({
|
return await this.models.SessionCreated.create({
|
||||||
uuid: sessionUuid,
|
uuid: sessionUuid,
|
||||||
created_at: currentTimestamp.toISOString(),
|
created_at: currentTimestamp.toISOString(),
|
||||||
expires_at: expiryTimestamp.toISOString(),
|
expires_at: expiryTimestamp.toISOString(),
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
async function isSessionValid(sessionUuid) {
|
async function isSessionValid(sessionUuid) {
|
||||||
const currentSession = await models.SessionCreated.findOne({
|
const currentSession = await models.SessionCreated.findOne({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue