mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
swapped if for entry
This commit is contained in:
parent
eadf3a7671
commit
79b5c177cd
@ -13,19 +13,20 @@ impl AuthProvider {
|
||||
}
|
||||
|
||||
pub fn query(&mut self, username: String, password: String) -> bool {
|
||||
if let Some(pass) = self.accounts.get(&username) {
|
||||
if pass != &password {
|
||||
let pwd = password.clone();
|
||||
if self.accounts.entry(username.clone()).or_insert_with(|| {
|
||||
info!("Registered new user '{}'", &username);
|
||||
pwd
|
||||
}) == &password
|
||||
{
|
||||
info!("User '{}' successfully authenticated", username);
|
||||
true
|
||||
} else {
|
||||
warn!(
|
||||
"User '{}' attempted to log in with invalid password '{}'!",
|
||||
username, password
|
||||
);
|
||||
return false;
|
||||
}
|
||||
info!("User '{}' successfully authenticated", username);
|
||||
} else {
|
||||
info!("Registered new user '{}'", username);
|
||||
self.accounts.insert(username, password);
|
||||
}
|
||||
true
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user