mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added ban message with reason when banned user attempts to login to server
This commit is contained in:
parent
f171e4e870
commit
fee79720ee
@ -141,6 +141,7 @@ https://account.veloren.net."#,
|
||||
"main.login.invalid_character": "The selected character is invalid",
|
||||
"main.login.client_crashed": "Client crashed",
|
||||
"main.login.not_on_whitelist": "You need a Whitelist entry by an Admin to join",
|
||||
"main.login.banned": "You have been banned with the following reason",
|
||||
|
||||
/// End Main screen section
|
||||
|
||||
|
@ -16,6 +16,7 @@ pub enum Error {
|
||||
AuthErr(String),
|
||||
AuthClientError(AuthClientError),
|
||||
AuthServerNotTrusted,
|
||||
Banned(String),
|
||||
/// Persisted character data is invalid or missing
|
||||
InvalidCharacter,
|
||||
//TODO: InvalidAlias,
|
||||
|
@ -455,6 +455,7 @@ impl Client {
|
||||
RegisterError::AuthError(err) => Error::AuthErr(err),
|
||||
RegisterError::InvalidCharacter => Error::InvalidCharacter,
|
||||
RegisterError::NotOnWhitelist => Error::NotOnWhitelist,
|
||||
RegisterError::Banned(reason) => Error::Banned(reason),
|
||||
});
|
||||
},
|
||||
ServerMsg::StateAnswer(Ok(ClientState::Registered)) => break Ok(()),
|
||||
|
@ -260,6 +260,7 @@ pub enum RequestStateError {
|
||||
pub enum RegisterError {
|
||||
AlreadyLoggedIn,
|
||||
AuthError(String),
|
||||
Banned(String),
|
||||
InvalidCharacter,
|
||||
NotOnWhitelist,
|
||||
//TODO: InvalidAlias,
|
||||
|
@ -61,8 +61,9 @@ impl LoginProvider {
|
||||
// if found, check name against whitelist or if user is admin
|
||||
.and_then(|(username, uuid)| {
|
||||
// user cannot join if they are listed on the banlist
|
||||
if banlist.len() > 0 && banlist.iter().any(|x| x.0.eq_ignore_ascii_case(&username)) {
|
||||
return Err(RegisterError::NotOnWhitelist);
|
||||
if let Some(ban_record) = banlist.iter().find(|x| x.0.eq_ignore_ascii_case(&username)) {
|
||||
// Pull reason string out of ban record and send a copy of it
|
||||
return Err(RegisterError::Banned(ban_record.1.clone()));
|
||||
}
|
||||
|
||||
// user can only join if he is admin, the whitelist is empty (everyone can join)
|
||||
|
@ -125,6 +125,13 @@ impl PlayState for MainMenuState {
|
||||
client::Error::NotOnWhitelist => {
|
||||
localized_strings.get("main.login.not_on_whitelist").into()
|
||||
},
|
||||
client::Error::Banned(reason) => {
|
||||
format!(
|
||||
"{}: {}",
|
||||
localized_strings.get("main.login.banned"),
|
||||
reason
|
||||
)
|
||||
},
|
||||
client::Error::InvalidCharacter => {
|
||||
localized_strings.get("main.login.invalid_character").into()
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user