Auth plugin compat with regular user accounts

pull/2737/head
Chocobozzz 2020-04-30 09:42:30 +02:00 committed by Chocobozzz
parent a5896799f1
commit e9b0fa5c16
1 changed files with 8 additions and 4 deletions

View File

@ -109,11 +109,15 @@ async function getUser (usernameOrEmail?: string, password?: string) {
let user = await UserModel.loadByEmail(obj.user.email)
if (!user) user = await createUserFromExternal(obj.pluginName, obj.user)
// 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
}
}
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.')