Browse Source

removed let banned and extra comments

pbs
Andy Newjack 5 years ago
committed by jake
parent
commit
02947adc98
  1. 7
      src/login/login.rs

7
src/login/login.rs

@ -60,10 +60,9 @@ pub fn get_login_status(entity_gateway: &dyn EntityGateway, pkt: &Login) -> Resu
let username = array_to_utf8(pkt.username).map_err(|_err| AccountStatus::Error)?; let username = array_to_utf8(pkt.username).map_err(|_err| AccountStatus::Error)?;
let password = array_to_utf8(pkt.password).map_err(|_err| AccountStatus::Error)?; let password = array_to_utf8(pkt.password).map_err(|_err| AccountStatus::Error)?;
let user = entity_gateway.get_user_by_name(username).ok_or(AccountStatus::InvalidUser)?; let user = entity_gateway.get_user_by_name(username).ok_or(AccountStatus::InvalidUser)?;
let banned = user.banned;
let verified = bcrypt::verify(password, user.password.as_str()).map_err(|_err| AccountStatus::Error)?; let verified = bcrypt::verify(password, user.password.as_str()).map_err(|_err| AccountStatus::Error)?;
match verified { match verified {
true => if banned {
true => if user.banned {
Err(AccountStatus::Banned) Err(AccountStatus::Banned)
} }
else { else {
@ -306,7 +305,7 @@ mod test {
flags: 0, flags: 0,
}) })
} }
} // end impl EntityGateway for TestData
}
let mut server = LoginServerState::new(TestData {}); let mut server = LoginServerState::new(TestData {});
let send = server.handle(ClientId(1), &LOGIN_PACKET).unwrap().collect::<Vec<_>>(); let send = server.handle(ClientId(1), &LOGIN_PACKET).unwrap().collect::<Vec<_>>();
@ -327,5 +326,5 @@ mod test {
}, },
caps: 258 caps: 258
}))]) }))])
} // end test_banned_user()
}
} }
Loading…
Cancel
Save