🔒 security: add auth token validation via Redis and DB check

This commit is contained in:
2026-02-17 21:51:14 +07:00
parent 3122f34093
commit 9686153a82
4 changed files with 54 additions and 3 deletions

View File

@ -0,0 +1,16 @@
import { AppError } from "../../../helpers/error/instances/app";
import { userSessionModel } from "../userSession.model";
export const checkUserSessionRepository = async (sessionId: string) => {
try {
return await userSessionModel.findUnique({
where: {
id: sessionId,
isAuthenticated: true,
deletedAt: null,
},
});
} catch (error) {
throw new AppError(500, "Database error during session validation", error);
}
};