Füge E-Mail-Benachrichtigungen für Sperrungen und zeitlich begrenzte Sperrungen hinzu
This commit is contained in:
@@ -56,6 +56,7 @@ import { setStandardName } from "../../../../../../helper/discord";
|
||||
import { penaltyColumns } from "(app)/admin/penalty/columns";
|
||||
import { addPenalty, editPenaltys } from "(app)/admin/penalty/actions";
|
||||
import { reportColumns } from "(app)/admin/report/columns";
|
||||
import { sendMail, sendMailByTemplate } from "../../../../../../helper/mail";
|
||||
|
||||
interface ProfileFormProps {
|
||||
user: User;
|
||||
@@ -349,6 +350,12 @@ export const UserPenalties = ({ user }: { user: User }) => {
|
||||
userId: user.id,
|
||||
createdUserId: createdUser.id,
|
||||
});
|
||||
if (user.email) {
|
||||
await sendMailByTemplate(user.email, "timeban-notice", {
|
||||
user,
|
||||
staffName: createdUser.firstname + " " + createdUser.lastname,
|
||||
});
|
||||
}
|
||||
penaltyTable.current?.refresh();
|
||||
toast.success("Time-Ban wurde hinzugefügt!");
|
||||
}}
|
||||
@@ -370,6 +377,12 @@ export const UserPenalties = ({ user }: { user: User }) => {
|
||||
userId: user.id,
|
||||
createdUserId: createdUser.id,
|
||||
});
|
||||
if (user.email) {
|
||||
await sendMailByTemplate(user.email, "ban-notice", {
|
||||
user,
|
||||
staffName: createdUser.firstname + " " + createdUser.lastname,
|
||||
});
|
||||
}
|
||||
await editUser(user.id, { isBanned: true });
|
||||
penaltyTable.current?.refresh();
|
||||
toast.success("Ban wurde hinzugefügt!");
|
||||
|
||||
@@ -58,42 +58,6 @@ export const deleteUser = async (id: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const checkEmailCode = async (code: string) => {
|
||||
const users = await prisma.user.findMany({
|
||||
where: {
|
||||
emailVerificationToken: code,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
emailVerificationToken: true,
|
||||
emailVerificationExpiresAt: true,
|
||||
},
|
||||
});
|
||||
const user = users[0];
|
||||
|
||||
if (!user || !user.emailVerificationExpiresAt) {
|
||||
return { error: "Code ist ungültig" };
|
||||
}
|
||||
|
||||
if (user.emailVerificationExpiresAt < new Date()) {
|
||||
return { error: "Code ist nicht mehr gültig" };
|
||||
}
|
||||
|
||||
await prisma.user.update({
|
||||
where: {
|
||||
id: user.id,
|
||||
},
|
||||
data: {
|
||||
emailVerified: true,
|
||||
emailVerificationToken: null,
|
||||
emailVerificationExpiresAt: null,
|
||||
},
|
||||
});
|
||||
return {
|
||||
message: "Email bestätigt!",
|
||||
};
|
||||
};
|
||||
|
||||
export const sendVerificationLink = async (userId: string) => {
|
||||
const code = Math.floor(10000 + Math.random() * 90000).toString();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user