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');
|
||||
|
||||
class SessionServiceProvider {
|
||||
constructor({ invitesService }) {
|
||||
constructor({ models, constants, invitesService }) {
|
||||
this.models = models;
|
||||
this.constants = constants;
|
||||
this.invitesService = invitesService;
|
||||
}
|
||||
|
||||
provide() {
|
||||
async function createSession(sessionUuid) {
|
||||
const createSession = async (sessionUuid) => {
|
||||
const currentTimestamp = new Date();
|
||||
const expiryTimestamp = new Date(currentTimestamp.getTime());
|
||||
expiryTimestamp.setSeconds(
|
||||
|
|
@ -18,12 +20,12 @@ class SessionServiceProvider {
|
|||
constants.DEFAULT_SESSION_DURATION_SECONDS
|
||||
);
|
||||
|
||||
return await models.SessionCreated.create({
|
||||
return await this.models.SessionCreated.create({
|
||||
uuid: sessionUuid,
|
||||
created_at: currentTimestamp.toISOString(),
|
||||
expires_at: expiryTimestamp.toISOString(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
async function isSessionValid(sessionUuid) {
|
||||
const currentSession = await models.SessionCreated.findOne({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue