add create user session service and controller

This commit is contained in:
rafiarrafif
2025-05-08 23:45:11 +07:00
parent a2c27b313a
commit 6f14300347
2 changed files with 8 additions and 1 deletions

View File

@ -6,10 +6,16 @@ import {
returnErrorResponse,
returnWriteResponse,
} from "../../../helpers/callback/httpResponse";
import { createUserSchema } from "../../user/user.schema";
export const createUserSessionRole = async (
ctx: Context & { body: { userId: string } }
ctx: Context & { body: { userId?: string } }
) => {
// Validate request body
if (!ctx.body?.userId) {
return returnErrorResponse(ctx.set, 400, "User ID is required");
}
const userHeaderData = getUserHeaderInformation(ctx);
try {

View File

@ -14,6 +14,7 @@ export const createUserSessionService = async (
deviceIp: data.userHeaderInformation.ip,
validUntil: new Date(new Date().getTime() + sessionLifetime * 1000),
});
return newUserSession;
} catch (error) {
throw error;
}