Added Account log for registration

This commit is contained in:
PxlLoewe
2026-01-30 16:56:22 +01:00
parent 2154684223
commit 10af6bf71a
3 changed files with 11 additions and 5 deletions

View File

@@ -26,9 +26,10 @@ export async function getOrSetDeviceId() {
export const logAction = async (
type: LOG_TYPE,
otherValues?: {
field: string;
oldValue: string;
newValue: string;
field?: string;
oldValue?: string;
newValue?: string;
userId?: string;
},
) => {
const headersList = await headers();
@@ -40,7 +41,7 @@ export const logAction = async (
headersList.get("X-Real-IP");
const deviceId = await getOrSetDeviceId();
if (type == "LOGIN") {
if (type == "LOGIN" || type == "REGISTER") {
const existingLogs = await prisma.log.findMany({
where: {
type: "LOGIN",
@@ -77,7 +78,7 @@ export const logAction = async (
data: {
type,
browser: headersList.get("user-agent") || "unknown",
userId: user?.user.id,
userId: user?.user.id || otherValues?.userId,
deviceId: deviceId,
ip,
...otherValues,