fix(password): set_salt(), check if is empty, fix condition

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2026-03-23 16:33:26 +08:00
parent 2d7b848516
commit f8358bd17e

View File

@@ -1346,16 +1346,16 @@ impl Config {
} }
if !password_is_empty_or_not_hashed(&config.password) { if !password_is_empty_or_not_hashed(&config.password) {
if config.salt.is_empty() { if config.salt.is_empty() {
log::error!(
"Refusing to set salt because permanent password is hashed and salt is empty"
);
return;
} else {
// This shouldn't happen under normal circumstances because the salt // This shouldn't happen under normal circumstances because the salt
// should be automatically generated when migrating to hash storage. // should be automatically generated when migrating to hash storage.
// However, if it does occur, it's best to log the error, // However, if it does occur, it's best to log the error,
// even though this will result in logging many duplicate error messages. // even though this will result in logging many duplicate error messages.
log::warn!("Salt is empty but permanent password is hashed"); log::warn!("Salt is empty but permanent password is hashed");
} else {
log::error!(
"Refusing to set salt because permanent password is hashed and salt is empty"
);
return;
} }
} }
config.salt = salt.into(); config.salt = salt.into();