store auth: Fix bug that app tokens were only usable when password is set

This commit is contained in:
Lennart
2024-11-03 13:10:52 +01:00
parent 45de287d72
commit 3ea004f75d

View File

@@ -44,11 +44,6 @@ impl AuthenticationProvider for StaticUserStore {
None => return Ok(None), None => return Ok(None),
}; };
let password = match &user_entry.user.password {
Some(password) => password,
None => return Ok(None),
};
// Try app tokens first since they are cheaper to calculate // Try app tokens first since they are cheaper to calculate
// They can afford less iterations since they can be generated with high entropy // They can afford less iterations since they can be generated with high entropy
for app_token in &user_entry.app_tokens { for app_token in &user_entry.app_tokens {
@@ -56,6 +51,12 @@ impl AuthenticationProvider for StaticUserStore {
return Ok(Some(user_entry.user)); return Ok(Some(user_entry.user));
} }
} }
let password = match &user_entry.user.password {
Some(password) => password,
None => return Ok(None),
};
if password_auth::verify_password(token, password).is_ok() { if password_auth::verify_password(token, password).is_ok() {
return Ok(Some(user_entry.user)); return Ok(Some(user_entry.user));
} }