From e9b0fa5c16ca196a3ba3267af4008782a3e86875 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 30 Apr 2020 09:42:30 +0200 Subject: [PATCH] Auth plugin compat with regular user accounts --- server/lib/oauth-model.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts index 8d8a6d85e..136abd0c4 100644 --- a/server/lib/oauth-model.ts +++ b/server/lib/oauth-model.ts @@ -109,10 +109,14 @@ async function getUser (usernameOrEmail?: string, password?: string) { let user = await UserModel.loadByEmail(obj.user.email) if (!user) user = await createUserFromExternal(obj.pluginName, obj.user) - // This user does not belong to this plugin, skip it - if (user.pluginAuth !== obj.pluginName) return null + // If the user does not belongs to a plugin, it was created before its installation + // Then we just go through a regular login process + if (user.pluginAuth !== null) { + // This user does not belong to this plugin, skip it + if (user.pluginAuth !== obj.pluginName) return null - return user + return user + } } logger.debug('Getting User (username/email: ' + usernameOrEmail + ', password: ******).') @@ -122,7 +126,7 @@ async function getUser (usernameOrEmail?: string, password?: string) { if (!user || user.pluginAuth !== null) return null const passwordMatch = await user.isPasswordMatch(password) - if (passwordMatch === false) return null + if (passwordMatch !== true) return null if (user.blocked) throw new AccessDeniedError('User is blocked.')