impr: better email changing logs

!nuf
This commit is contained in:
Miodec 2025-01-15 10:52:48 +01:00
parent bc999c2ab3
commit 3a065313bf
2 changed files with 4 additions and 3 deletions

View file

@ -1068,7 +1068,7 @@ describe("user controller test", () => {
);
expect(addImportantLogMock).toHaveBeenCalledWith(
"user_email_updated",
"changed email to newemail@example.com",
"changed email from previousemail@example.com to newemail@example.com",
uid
);
});

View file

@ -405,9 +405,10 @@ export async function updateEmail(
req: MonkeyRequest<undefined, UpdateEmailRequestSchema>
): Promise<MonkeyResponse> {
const { uid } = req.ctx.decodedToken;
let { newEmail } = req.body;
let { newEmail, previousEmail } = req.body;
newEmail = newEmail.toLowerCase();
previousEmail = previousEmail.toLowerCase();
try {
await AuthUtil.updateUserEmail(uid, newEmail);
@ -440,7 +441,7 @@ export async function updateEmail(
void addImportantLog(
"user_email_updated",
`changed email to ${newEmail}`,
`changed email from ${previousEmail} to ${newEmail}`,
uid
);