🔒 security: add auth token validation via Redis and DB check
This commit is contained in:
@ -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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user