From 0a150ad3439a2825ad0ed5ee6f5faa04eb621134 Mon Sep 17 00:00:00 2001 From: oat Date: Mon, 12 Oct 2020 20:56:06 +0300 Subject: [PATCH 1/2] one more auth fix --- src/auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth.ts b/src/auth.ts index abe5f73..50afb1a 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -33,7 +33,7 @@ export function run(app) { } }); - const users = await User.find({id: userInfo.id}); + const users = await User.find({id: String(userInfo.data.id)}); let userUuid = ''; if (users.length === 0) { From 4cbe2528529534c7bb3f102d6253d019a67d4401 Mon Sep 17 00:00:00 2001 From: oat Date: Mon, 12 Oct 2020 21:13:45 +0300 Subject: [PATCH 2/2] 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');