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.invalid_character": "The selected character is invalid",
|
||||||
"main.login.client_crashed": "Client crashed",
|
"main.login.client_crashed": "Client crashed",
|
||||||
"main.login.not_on_whitelist": "You need a Whitelist entry by an Admin to join",
|
"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
|
/// End Main screen section
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ pub enum Error {
|
|||||||
AuthErr(String),
|
AuthErr(String),
|
||||||
AuthClientError(AuthClientError),
|
AuthClientError(AuthClientError),
|
||||||
AuthServerNotTrusted,
|
AuthServerNotTrusted,
|
||||||
|
Banned(String),
|
||||||
/// Persisted character data is invalid or missing
|
/// Persisted character data is invalid or missing
|
||||||
InvalidCharacter,
|
InvalidCharacter,
|
||||||
//TODO: InvalidAlias,
|
//TODO: InvalidAlias,
|
||||||
|
@ -455,6 +455,7 @@ impl Client {
|
|||||||
RegisterError::AuthError(err) => Error::AuthErr(err),
|
RegisterError::AuthError(err) => Error::AuthErr(err),
|
||||||
RegisterError::InvalidCharacter => Error::InvalidCharacter,
|
RegisterError::InvalidCharacter => Error::InvalidCharacter,
|
||||||
RegisterError::NotOnWhitelist => Error::NotOnWhitelist,
|
RegisterError::NotOnWhitelist => Error::NotOnWhitelist,
|
||||||
|
RegisterError::Banned(reason) => Error::Banned(reason),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
ServerMsg::StateAnswer(Ok(ClientState::Registered)) => break Ok(()),
|
ServerMsg::StateAnswer(Ok(ClientState::Registered)) => break Ok(()),
|
||||||
|
@ -260,6 +260,7 @@ pub enum RequestStateError {
|
|||||||
pub enum RegisterError {
|
pub enum RegisterError {
|
||||||
AlreadyLoggedIn,
|
AlreadyLoggedIn,
|
||||||
AuthError(String),
|
AuthError(String),
|
||||||
|
Banned(String),
|
||||||
InvalidCharacter,
|
InvalidCharacter,
|
||||||
NotOnWhitelist,
|
NotOnWhitelist,
|
||||||
//TODO: InvalidAlias,
|
//TODO: InvalidAlias,
|
||||||
|
@ -61,8 +61,9 @@ impl LoginProvider {
|
|||||||
// if found, check name against whitelist or if user is admin
|
// if found, check name against whitelist or if user is admin
|
||||||
.and_then(|(username, uuid)| {
|
.and_then(|(username, uuid)| {
|
||||||
// user cannot join if they are listed on the banlist
|
// 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)) {
|
if let Some(ban_record) = banlist.iter().find(|x| x.0.eq_ignore_ascii_case(&username)) {
|
||||||
return Err(RegisterError::NotOnWhitelist);
|
// 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)
|
// 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 => {
|
client::Error::NotOnWhitelist => {
|
||||||
localized_strings.get("main.login.not_on_whitelist").into()
|
localized_strings.get("main.login.not_on_whitelist").into()
|
||||||
},
|
},
|
||||||
|
client::Error::Banned(reason) => {
|
||||||
|
format!(
|
||||||
|
"{}: {}",
|
||||||
|
localized_strings.get("main.login.banned"),
|
||||||
|
reason
|
||||||
|
)
|
||||||
|
},
|
||||||
client::Error::InvalidCharacter => {
|
client::Error::InvalidCharacter => {
|
||||||
localized_strings.get("main.login.invalid_character").into()
|
localized_strings.get("main.login.invalid_character").into()
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user