mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 15:26:15 +08:00
Add logic to handle duplicate names (#2958)
This commit is contained in:
parent
c50218f709
commit
cdbc0bf770
|
@ -64,9 +64,13 @@ export async function updateName(
|
|||
throw new MonkeyError(400, "Invalid username");
|
||||
}
|
||||
|
||||
return await db
|
||||
.collection<MonkeyTypes.User>("users")
|
||||
.updateOne({ uid }, { $set: { name, lastNameChange: Date.now() } });
|
||||
return await getUsersCollection().updateOne(
|
||||
{ uid },
|
||||
{
|
||||
$set: { name, lastNameChange: Date.now() },
|
||||
$unset: { needsToUpdateName: "" },
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function clearPb(uid: string): Promise<UpdateResult> {
|
||||
|
|
1
backend/src/types/types.d.ts
vendored
1
backend/src/types/types.d.ts
vendored
|
@ -71,6 +71,7 @@ declare namespace MonkeyTypes {
|
|||
banned?: boolean;
|
||||
canManageApeKeys?: boolean;
|
||||
favoriteQuotes?: Record<string, string[]>;
|
||||
needsToUpdateName?: boolean;
|
||||
}
|
||||
|
||||
type UserQuoteRatings = Record<string, Record<string, number>>;
|
||||
|
|
Loading…
Reference in a new issue