add log for delet account
This commit is contained in:
2
apps/dispatch/next-env.d.ts
vendored
2
apps/dispatch/next-env.d.ts
vendored
@@ -1,6 +1,6 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
import "./.next/types/routes.d.ts";
|
import "./.next/dev/types/routes.d.ts";
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { prisma, Prisma } from "@repo/db";
|
|||||||
import bcrypt from "bcryptjs";
|
import bcrypt from "bcryptjs";
|
||||||
import { sendMailByTemplate } from "../../../../helper/mail";
|
import { sendMailByTemplate } from "../../../../helper/mail";
|
||||||
import { getServerSession } from "api/auth/[...nextauth]/auth";
|
import { getServerSession } from "api/auth/[...nextauth]/auth";
|
||||||
|
import { logAction } from "(auth)/login/_components/action";
|
||||||
|
|
||||||
export const getUser = async (where: Prisma.UserWhereInput) => {
|
export const getUser = async (where: Prisma.UserWhereInput) => {
|
||||||
return await prisma.user.findMany({
|
return await prisma.user.findMany({
|
||||||
@@ -58,6 +59,7 @@ export const deletePilotHistory = async (id: number) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
export const deleteUser = async (id: string) => {
|
export const deleteUser = async (id: string) => {
|
||||||
|
await logAction("ACCOUNT_DELETED");
|
||||||
return await prisma.user.update({
|
return await prisma.user.update({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export const resetPassword = async (email: string) => {
|
|||||||
let user = await prisma.user.findFirst({
|
let user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
email,
|
email,
|
||||||
|
isDeleted: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const oldUser = (v1User as OldUser[]).find((u) => u.email.toLowerCase() === email);
|
const oldUser = (v1User as OldUser[]).find((u) => u.email.toLowerCase() === email);
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ export const register = async ({ password, ...user }: Omit<Prisma.UserCreateInpu
|
|||||||
where: {
|
where: {
|
||||||
email: user.email,
|
email: user.email,
|
||||||
},
|
},
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const existingOldUser = (v1User as OldUser[]).find(
|
const existingOldUser = (v1User as OldUser[]).find(
|
||||||
@@ -34,10 +31,16 @@ export const register = async ({ password, ...user }: Omit<Prisma.UserCreateInpu
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (existingUser) {
|
if (existingUser) {
|
||||||
|
if (existingUser.isDeleted) {
|
||||||
|
return {
|
||||||
|
error: "Diese E-Mail-Adresse kann nicht verwendet werden.",
|
||||||
|
};
|
||||||
|
} else {
|
||||||
return {
|
return {
|
||||||
error: "Ein Nutzer mit dieser E-Mail-Adresse existiert bereits.",
|
error: "Ein Nutzer mit dieser E-Mail-Adresse existiert bereits.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (existingOldUser) {
|
if (existingOldUser) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterEnum
|
||||||
|
ALTER TYPE "LOG_TYPE" ADD VALUE 'ACCOUNT_DELETED';
|
||||||
Reference in New Issue
Block a user