From 4cbe2528529534c7bb3f102d6253d019a67d4401 Mon Sep 17 00:00:00 2001 From: oat Date: Mon, 12 Oct 2020 21:13:45 +0300 Subject: [PATCH] now no two users can have the same uuid --- src/auth.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/auth.ts b/src/auth.ts index 50afb1a..8a64c16 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -37,6 +37,12 @@ export function run(app) { let userUuid = ''; if (users.length === 0) { + let newUuid = uuid.v4(); + + while (User.find({uuid: newUuid})[0]) { + newUuid = uuid.v4(); + } + const newUser = new User({ id: String(userInfo.data.id), createdAt: new Date(), @@ -45,7 +51,7 @@ export function run(app) { discriminator: userInfo.data.discriminator, avatar: userInfo.data.avatar, - uuid: uuid.v4(), + uuid: newUuid, }); userUuid = newUser.get('uuid');