From 0b9ff6346a40b810deb0a6b7c83c94f221c65cb8 Mon Sep 17 00:00:00 2001 From: MattPlayGamez <62027538+MattPlayGamez@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:40:55 +0200 Subject: [PATCH] fixed an issue with user being lock. Now by default the locked(=false) attribute has been given to a user --- file.js | 3 +++ memory.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/file.js b/file.js index df9a9a8..fbf1fbf 100644 --- a/file.js +++ b/file.js @@ -97,6 +97,8 @@ class Authenticator { if (!userObject.loginAttempts) userObject.loginAttempts = 0 if (!userObject.locked) userObject.locked = false if (!userObject._id) userObject._id = uuid.v4() + userObject.locked = false + userObject.emailCode = null let returnedUser = userObject try { const hash = await bcrypt.hash(userObject.password, this.rounds); @@ -115,6 +117,7 @@ class Authenticator { userObject.password = hash; userObject.jwt_version = 1 + if (this.users.find(u => u.email === userObject.email)) return this.USER_ALREADY_EXISTS_TEXT this.users.push(userObject); return returnedUser; diff --git a/memory.js b/memory.js index accf7e2..9e4a3d0 100644 --- a/memory.js +++ b/memory.js @@ -43,6 +43,8 @@ class Authenticator { if (!userObject.loginAttempts) userObject.loginAttempts = 0 if (!userObject.locked) userObject.locked = false if (!userObject._id) userObject._id = uuid.v4() + userObject.locked = false + userObject.emailCode = null let returnedUser = userObject try { const hash = await bcrypt.hash(userObject.password, this.rounds);