Fix:Server crash when user without a password attempts to login with a password #2378

This commit is contained in:
advplyr 2023-12-02 16:17:52 -06:00
parent fbc2c2b481
commit 84160b2f07

View File

@ -542,13 +542,13 @@ class Auth {
// Load the user given it's username // Load the user given it's username
const user = await Database.userModel.getUserByUsername(username.toLowerCase()) const user = await Database.userModel.getUserByUsername(username.toLowerCase())
if (!user || !user.isActive) { if (!user?.isActive) {
done(null, null) done(null, null)
return return
} }
// Check passwordless root user // Check passwordless root user
if (user.type === 'root' && (!user.pash || user.pash === '')) { if (user.type === 'root' && !user.pash) {
if (password) { if (password) {
// deny login // deny login
done(null, null) done(null, null)
@ -557,6 +557,10 @@ class Auth {
// approve login // approve login
done(null, user) done(null, user)
return return
} else if (!user.pash) {
Logger.error(`[Auth] User "${user.username}"/"${user.type}" attempted to login without a password set`)
done(null, null)
return
} }
// Check password match // Check password match