add userSession module
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
import { createUserSessionServiceParams } from "../userSession.types";
|
||||
import { createUserSessionRepo } from "../userSession.repository";
|
||||
|
||||
export const createUserSessionService = async (
|
||||
data: createUserSessionServiceParams
|
||||
) => {
|
||||
const sessionLifetime = Number(process.env.SESSION_EXPIRE!);
|
||||
try {
|
||||
const newUserSession = await createUserSessionRepo({
|
||||
userId: data.userId,
|
||||
isAuthenticated: true,
|
||||
deviceType: data.userHeaderInformation.deviceType,
|
||||
deviceOs: data.userHeaderInformation.deviceOS,
|
||||
deviceIp: data.userHeaderInformation.ip,
|
||||
validUntil: new Date(new Date().getTime() + sessionLifetime * 1000),
|
||||
});
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user