mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-17 19:15:59 +08:00
storing name history
This commit is contained in:
parent
b9c1f1219c
commit
dc7295f3f6
1 changed files with 8 additions and 0 deletions
|
@ -59,6 +59,8 @@ export async function updateName(
|
|||
|
||||
const user = await getUser(uid, "update name");
|
||||
|
||||
const oldName = user.name;
|
||||
|
||||
if (
|
||||
!user?.needsToChangeName &&
|
||||
Date.now() - (user.lastNameChange ?? 0) < THIRTY_DAYS_IN_SECONDS
|
||||
|
@ -66,6 +68,12 @@ export async function updateName(
|
|||
throw new MonkeyError(409, "You can change your name once every 30 days");
|
||||
}
|
||||
|
||||
await getUsersCollection().updateOne(
|
||||
{ uid },
|
||||
{
|
||||
$push: { nameHistory: oldName },
|
||||
}
|
||||
);
|
||||
return await getUsersCollection().updateOne(
|
||||
{ uid },
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue