diff --git a/assets/voxygen/i18n/PL/_manifest.ron b/assets/voxygen/i18n/PL/_manifest.ron index 415e236d91..49895355b0 100644 --- a/assets/voxygen/i18n/PL/_manifest.ron +++ b/assets/voxygen/i18n/PL/_manifest.ron @@ -125,7 +125,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "ServerWentMad: Prawdopodobnie wersje są niekompatybilne, sprawdź aktualizacje!", "main.login.timeout": "Timeout: Serwer nie odpowiedział na czas. (Przeciążenie, bądź błędy sieci).", "main.login.server_shut_down": "Serwer zamknięty", - "main.login.already_logged_in": "Jesteś już zalogowany na serwerze.", "main.login.network_error": "Błąd sieci.", "main.login.failed_sending_request": "Zapytanie do serwera weryfikacji nie powiodło się", "main.login.client_crashed": "Crash clienta", diff --git a/assets/voxygen/i18n/de_DE/_manifest.ron b/assets/voxygen/i18n/de_DE/_manifest.ron index 4326243bf3..60917901b9 100644 --- a/assets/voxygen/i18n/de_DE/_manifest.ron +++ b/assets/voxygen/i18n/de_DE/_manifest.ron @@ -149,7 +149,6 @@ https://veloren.net/account/. "main.login.outdated_client_or_server": "Inkompatible Version", "main.login.timeout": "Zeitüberschreitung", "main.login.server_shut_down": "Server heruntergefahren", - "main.login.already_logged_in": "Ihr seid bereits eingeloggt", "main.login.network_error": "Netzwerkfehler", "main.login.failed_sending_request": "Authentifizierung fehlgeschlagen", "main.login.invalid_character": "Ungültiger Charakter", diff --git a/assets/voxygen/i18n/en/main.ron b/assets/voxygen/i18n/en/main.ron index ac9adf55ab..9b3069856f 100644 --- a/assets/voxygen/i18n/en/main.ron +++ b/assets/voxygen/i18n/en/main.ron @@ -48,7 +48,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "ServerWentMad: Probably versions are incompatible, check for updates.", "main.login.timeout": "Timeout: Server did not respond in time. (Overloaded or network issues).", "main.login.server_shut_down": "Server shut down", - "main.login.already_logged_in": "You are already logged into the server.", "main.login.network_error": "Network error", "main.login.network_wrong_version": "The server is running a different version than you are. Check your version and update your game.", "main.login.failed_sending_request": "Request to Auth server failed", diff --git a/assets/voxygen/i18n/es_ES/main.ron b/assets/voxygen/i18n/es_ES/main.ron index d949f497bc..9c00d1cc85 100644 --- a/assets/voxygen/i18n/es_ES/main.ron +++ b/assets/voxygen/i18n/es_ES/main.ron @@ -49,7 +49,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "ServerEnloquecido: Probablemente las versiones son incompatibles, revisa si hay actualizaciones.", "main.login.timeout": "Timeout: El servidor no respondió a tiempo. (Sobrecargado o con problemas de red).", "main.login.server_shut_down": "Servidor apagado", - "main.login.already_logged_in": "Ya estás conectado al servidor.", "main.login.network_error": "Error de red", "main.login.network_wrong_version": "El servidor está ejecutando una versión diferente a la tuya. Comprueba tu versión y actualiza tu juego.", "main.login.failed_sending_request": "Petición al servidor de autenticación fallida", diff --git a/assets/voxygen/i18n/es_la/_manifest.ron b/assets/voxygen/i18n/es_la/_manifest.ron index e54485fc71..6df5839ae8 100644 --- a/assets/voxygen/i18n/es_la/_manifest.ron +++ b/assets/voxygen/i18n/es_la/_manifest.ron @@ -150,7 +150,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "ServidorEnloquecido: Probablemente las versiones son incompatibles, intenta actualizar tu cliente.", "main.login.timeout": "Tiempo de espera agotado: El servidor no respondio a tiempo. (Puede estar sobrecargado o tener problemas de red).", "main.login.server_shut_down": "El servidor se apagó", - "main.login.already_logged_in": "Ya estás conectado al servidor.", "main.login.network_error": "Error de red", "main.login.failed_sending_request": "El pedido al servidor de autenticacion fallo", "main.login.invalid_character": "El personaje seleccionado no es válido", diff --git a/assets/voxygen/i18n/fr_FR/main.ron b/assets/voxygen/i18n/fr_FR/main.ron index 3dd4bd130b..690870a7e3 100644 --- a/assets/voxygen/i18n/fr_FR/main.ron +++ b/assets/voxygen/i18n/fr_FR/main.ron @@ -46,7 +46,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "ServeurPasContent: Les versions sont probablement incompatibles, verifiez les mises à jour.", "main.login.timeout": "DélaiEcoulé: Le serveur n'a pas répondu à temps. (Surchage ou problèmes réseau).", "main.login.server_shut_down": "Extinction du Serveur", - "main.login.already_logged_in": "Vous êtes déjà connecté sur ce serveur.", "main.login.network_error": "Problème Réseau", "main.login.network_wrong_version": "Le serveur fonctionne avec une version différente de la vôtre. Vérifiez votre version et mettez votre jeu à jour.", "main.login.failed_sending_request": "Demande d'authentification serveur échouée", diff --git a/assets/voxygen/i18n/it_IT/_manifest.ron b/assets/voxygen/i18n/it_IT/_manifest.ron index 1d06e11ded..3022b32cf8 100644 --- a/assets/voxygen/i18n/it_IT/_manifest.ron +++ b/assets/voxygen/i18n/it_IT/_manifest.ron @@ -171,7 +171,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "Il server è impazzito: Probabilmente le versioni sono incompatibili, controlla per degli aggiornamenti", "main.login.timeout": "Tempo scaduto: Il server non ha risposto in tempo. (In sovraccarico o problemi di rete)", "main.login.server_shut_down": "Il server è stato chiuso", - "main.login.already_logged_in": "Hai già effettuato l'accesso al server", "main.login.network_error": "Errore di rete", "main.login.failed_sending_request": "Richiesta ai server di autenticazione fallita", "main.login.invalid_character": "Il personaggio selezionato è invalido", diff --git a/assets/voxygen/i18n/nl/_manifest.ron b/assets/voxygen/i18n/nl/_manifest.ron index 7997dc1fdb..385f42fa12 100644 --- a/assets/voxygen/i18n/nl/_manifest.ron +++ b/assets/voxygen/i18n/nl/_manifest.ron @@ -148,7 +148,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "Versieprobleem: De versie tussen de client en de server komen niet overeen. Check of er updates zijn/", "main.login.timeout": "Timeout: De server deed er te lang over om te antwoorden. (Overblast of netwerk problemen).", "main.login.server_shut_down": "Server is afgesloten", - "main.login.already_logged_in": "Je account is al reeds ingelogd op de server.", "main.login.network_error": "Network problemen", "main.login.failed_sending_request": "Kon verzoek niet naar authenticatie server sturen", "main.login.invalid_character": "Het geselecteerde karakter is ongeldig", diff --git a/assets/voxygen/i18n/no/_manifest.ron b/assets/voxygen/i18n/no/_manifest.ron index 9e6a7677c3..ed7673cc49 100644 --- a/assets/voxygen/i18n/no/_manifest.ron +++ b/assets/voxygen/i18n/no/_manifest.ron @@ -150,7 +150,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "Sannsynligvis er versjoner inkompatible, se etter oppdateringer.", "main.login.timeout": "Serveren svarte ikke i tide. (Overbelastet eller nettverksproblemer).", "main.login.server_shut_down": "Serveren stoppet", - "main.login.already_logged_in": "Du er allerede logget på serveren.", "main.login.network_error": "Nettverksfeil", "main.login.failed_sending_request": "Forespørsel til godkjenningsserver mislyktes", "main.login.invalid_character": "Den valgte karakteren er ugyldig", diff --git a/assets/voxygen/i18n/pt_BR/main.ron b/assets/voxygen/i18n/pt_BR/main.ron index 25d13831e0..e5d2d7f47f 100644 --- a/assets/voxygen/i18n/pt_BR/main.ron +++ b/assets/voxygen/i18n/pt_BR/main.ron @@ -45,7 +45,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "Servidor enlouqueceu: Provavelmente as versões são incompatíveis. Verifique se há atualizações.", "main.login.timeout": "Tempo esgotado: Servidor não respondeu a tempo. (Sobrecarregado ou com problemas de rede).", "main.login.server_shut_down": "Servidor encerrou ou desligou", - "main.login.already_logged_in": "Você já está logado neste servidor.", "main.login.network_error": "Erro de Rede", "main.login.failed_sending_request": "Requisição ao servidor de autenticação falhou", "main.login.invalid_character": "O personagem selecionado é inválido", diff --git a/assets/voxygen/i18n/pt_PT/_manifest.ron b/assets/voxygen/i18n/pt_PT/_manifest.ron index 7aa830fd9b..9a87cf22c9 100644 --- a/assets/voxygen/i18n/pt_PT/_manifest.ron +++ b/assets/voxygen/i18n/pt_PT/_manifest.ron @@ -123,7 +123,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "Servidor endoideceu: Provavelmente as versões são incompativéis, verifique se há versões mais recentes.", "main.login.timeout": "Tempo esgotado: O servidor não respondeu a tempo. (Sobrecarregado ou problemas de rede).", "main.login.server_shut_down": "O servidor encerrou", - "main.login.already_logged_in": "Vocé ja está logado neste servidor.", "main.login.network_error": "Error de rede", "main.login.failed_sending_request": "Pedido ao servidor de autenticação falhou", "main.login.client_crashed": "O cliente crashou", diff --git a/assets/voxygen/i18n/ru_RU/_manifest.ron b/assets/voxygen/i18n/ru_RU/_manifest.ron index 59cccf95fe..b3844898b4 100644 --- a/assets/voxygen/i18n/ru_RU/_manifest.ron +++ b/assets/voxygen/i18n/ru_RU/_manifest.ron @@ -149,7 +149,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "ServerWentMad: Возможно, версии несовместимы. Проверьте наличие обновлений.", "main.login.timeout": "Timeout: Сервер не ответил вовремя. (Перегрузка или проблемы с сетью).", "main.login.server_shut_down": "Сервер выключен", - "main.login.already_logged_in": "Вы уже вошли на сервер.", "main.login.network_error": "Ошибка сети", "main.login.failed_sending_request": "Запрос аутентификации провален", "main.login.invalid_character": "Выбранный персонаж недоступен", diff --git a/assets/voxygen/i18n/tr_TR/main.ron b/assets/voxygen/i18n/tr_TR/main.ron index 9daedffbc4..5df46b198d 100644 --- a/assets/voxygen/i18n/tr_TR/main.ron +++ b/assets/voxygen/i18n/tr_TR/main.ron @@ -48,7 +48,6 @@ bir hesap oluşturabilirsin."#, "main.login.outdated_client_or_server": "SunucuÇılgınaDöndü: Muhtemelen versiyonlar uyuşmuyor, güncellemeleri kontrol et.", "main.login.timeout": "Zamanaşımı: Sunucu zamanında cevap vermedi. (Aşırı yüklenme veya ağ sorunları).", "main.login.server_shut_down": "Sunucu kapandı", - "main.login.already_logged_in": "Zaten sunucuya giriş yapmışsın.", "main.login.network_error": "Ağ hatası", "main.login.failed_sending_request": "Kimlik doğrulama sunucusuna istek gönderilemedi", "main.login.invalid_character": "Seçilen karakter geçersiz", diff --git a/assets/voxygen/i18n/uk_UA/main.ron b/assets/voxygen/i18n/uk_UA/main.ron index 7fe4fc011c..e720f9b8b7 100644 --- a/assets/voxygen/i18n/uk_UA/main.ron +++ b/assets/voxygen/i18n/uk_UA/main.ron @@ -45,7 +45,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "Помилка: ймовірно версії не сумісні, перевірте оновлення.", "main.login.timeout": "Тайм-аут: сервер не відповів вчасно (перенавантажений, або проблеми з Вашою мережею).", "main.login.server_shut_down": "Сервер вимкнено", - "main.login.already_logged_in": "Ви вже підключені до сервера.", "main.login.network_error": "Помилка мережі", "main.login.failed_sending_request": "Запит до сервера авторизації невдалий", "main.login.invalid_character": "Обраний персонаж недоступний", diff --git a/assets/voxygen/i18n/zh_CN/_manifest.ron b/assets/voxygen/i18n/zh_CN/_manifest.ron index 417dd56411..9c7f4f3827 100644 --- a/assets/voxygen/i18n/zh_CN/_manifest.ron +++ b/assets/voxygen/i18n/zh_CN/_manifest.ron @@ -136,7 +136,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "服务器与客户端可能版本不兼容,请检查更新.", "main.login.timeout": "超时: 服务器无法及时响应.", "main.login.server_shut_down": "服务器已关闭", - "main.login.already_logged_in": "您已登入服务器.", "main.login.network_error": "网络错误", "main.login.failed_sending_request": "认证服务器请求失败", "main.login.invalid_character": "选择的角色无效", diff --git a/assets/voxygen/i18n/zh_TW/_manifest.ron b/assets/voxygen/i18n/zh_TW/_manifest.ron index 45b8d3d95a..679a4ad467 100644 --- a/assets/voxygen/i18n/zh_TW/_manifest.ron +++ b/assets/voxygen/i18n/zh_TW/_manifest.ron @@ -118,7 +118,6 @@ https://veloren.net/account/."#, "main.login.outdated_client_or_server": "伺服器錯誤:版本可能不相容,請檢查更新。", "main.login.timeout": "逾時:伺服器無法即時回應(也許試過載或者網路問題)。", "main.login.server_shut_down": "伺服器已關閉", - "main.login.already_logged_in": "您已登入伺服器。", "main.login.network_error": "網路錯誤", "main.login.failed_sending_request": "認證伺服器請求失敗", "main.login.client_crashed": "客戶端崩潰", diff --git a/client/src/error.rs b/client/src/error.rs index 02905f585d..57de911e94 100644 --- a/client/src/error.rs +++ b/client/src/error.rs @@ -13,7 +13,6 @@ pub enum Error { ServerShutdown, TooManyPlayers, NotOnWhitelist, - AlreadyLoggedIn, AuthErr(String), AuthClientError(AuthClientError), AuthServerUrlInvalid(String), diff --git a/client/src/lib.rs b/client/src/lib.rs index 4066c36bc4..9b2727f6af 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -538,7 +538,6 @@ impl Client { self.send_msg_err(ClientRegister { token_or_username })?; match self.register_stream.recv::().await? { - Err(RegisterError::AlreadyLoggedIn(_, _)) => Err(Error::AlreadyLoggedIn), Err(RegisterError::AuthError(err)) => Err(Error::AuthErr(err)), Err(RegisterError::InvalidCharacter) => Err(Error::InvalidCharacter), Err(RegisterError::NotOnWhitelist) => Err(Error::NotOnWhitelist), diff --git a/common/net/src/msg/server.rs b/common/net/src/msg/server.rs index b497bcd9c3..76d9edbb18 100644 --- a/common/net/src/msg/server.rs +++ b/common/net/src/msg/server.rs @@ -10,7 +10,6 @@ use common::{ terrain::{Block, TerrainChunk}, trade::{PendingTrade, TradeId, TradeResult}, uid::Uid, - uuid::Uuid, }; use hashbrown::HashMap; use serde::{Deserialize, Serialize}; @@ -192,7 +191,6 @@ pub enum DisconnectReason { #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub enum RegisterError { - AlreadyLoggedIn(Uuid, String), AuthError(String), Banned(String), Kicked(String), diff --git a/server/src/login_provider.rs b/server/src/login_provider.rs index 34e8c3e863..97e2292a59 100644 --- a/server/src/login_provider.rs +++ b/server/src/login_provider.rs @@ -44,6 +44,18 @@ impl Component for PendingLogin { type Storage = IdvStorage; } +#[derive(Debug)] +pub enum LoginError { + AlreadyLoggedIn(Uuid, String), + RegisterError(RegisterError), +} + +impl From for LoginError { + fn from(inner: RegisterError) -> LoginError { + LoginError::RegisterError(inner) + } +} + pub struct LoginProvider { runtime: Arc, accounts: HashMap, @@ -74,10 +86,10 @@ impl LoginProvider { } } - fn login(&mut self, uuid: Uuid, username: String) -> Result<(), RegisterError> { + fn login(&mut self, uuid: Uuid, username: String) -> Result<(), LoginError> { // make sure that the user is not logged in already if self.accounts.contains_key(&uuid) { - return Err(RegisterError::AlreadyLoggedIn(uuid, username)); + return Err(LoginError::AlreadyLoggedIn(uuid, username)); } info!(?username, "New User"); self.accounts.insert(uuid, username); @@ -121,19 +133,19 @@ impl LoginProvider { admins: &HashSet, whitelist: &HashSet, banlist: &HashMap, - ) -> Option> { + ) -> Option> { match pending.pending_r.try_recv() { - Ok(Err(e)) => Some(Err(e)), + Ok(Err(e)) => Some(Err(e.into())), Ok(Ok((username, uuid))) => { if let Some(ban_record) = banlist.get(&uuid) { // Pull reason string out of ban record and send a copy of it - return Some(Err(RegisterError::Banned(ban_record.reason.clone()))); + return Some(Err(RegisterError::Banned(ban_record.reason.clone()).into())); } // user can only join if he is admin, the whitelist is empty (everyone can join) // or his name is in the whitelist if !whitelist.is_empty() && !whitelist.contains(&uuid) && !admins.contains(&uuid) { - return Some(Err(RegisterError::NotOnWhitelist)); + return Some(Err(RegisterError::NotOnWhitelist.into())); } #[cfg(feature = "plugins")] { @@ -144,7 +156,7 @@ impl LoginProvider { Ok(e) => { for i in e.into_iter() { if let PlayerJoinResult::Kick(a) = i { - return Some(Err(RegisterError::Kicked(a))); + return Some(Err(RegisterError::Kicked(a).into())); } } }, @@ -164,7 +176,7 @@ impl LoginProvider { error!("channel got closed to early, this shouldn't happen"); Some(Err(RegisterError::AuthError( "Internal Error verifying".to_string(), - ))) + ).into())) }, Err(tokio::sync::oneshot::error::TryRecvError::Empty) => None, } diff --git a/server/src/sys/msg/register.rs b/server/src/sys/msg/register.rs index cbbbc990b7..9a47323189 100644 --- a/server/src/sys/msg/register.rs +++ b/server/src/sys/msg/register.rs @@ -1,9 +1,4 @@ -use crate::{ - client::Client, - login_provider::{LoginProvider, PendingLogin}, - metrics::PlayerMetrics, - EditableSettings, -}; +use crate::{EditableSettings, client::Client, login_provider::{LoginError, LoginProvider, PendingLogin}, metrics::PlayerMetrics}; use common::{ comp::{Admin, Player, Stats}, event::{EventBus, ServerEvent}, @@ -130,38 +125,35 @@ impl<'a> System<'a> for Sys { finished_pending.push(entity); trace!(?r, "pending login returned"); match r { - Err(e) => { - let mut retry = false; - if let RegisterError::AlreadyLoggedIn(uuid, ref username) = e { - if let Some((old_entity, old_client, _)) = - (&entities, &clients, &players) - .join() - .find(|(_, _, old_player)| old_player.uuid() == uuid) - { - // Remove old client - server_event_bus - .emit_now(ServerEvent::ClientDisconnect(old_entity)); - let _ = old_client.send(ServerGeneral::Disconnect( - DisconnectReason::Kicked(String::from( - "You have logged in from another location.", - )), - )); - // We can't login the new client right now as the - // removal of the old client and player occurs later in - // the tick, so we instead setup the new login to be - // processed in the next tick - // Create "fake" successful pending auth and mark it to - // be inserted into pending_logins at the end of this - // run - retries.push(( - entity, - PendingLogin::new_success(username.to_string(), uuid), - )); - retry = true; - } - } - if !retry { - client.send(ServerRegisterAnswer::Err(e))?; + Err(LoginError::RegisterError(e)) => { + client.send(ServerRegisterAnswer::Err(e))?; + return Ok(()); + } + Err(LoginError::AlreadyLoggedIn(uuid, ref username)) => { + if let Some((old_entity, old_client, _)) = + (&entities, &clients, &players) + .join() + .find(|(_, _, old_player)| old_player.uuid() == uuid) + { + // Remove old client + server_event_bus + .emit_now(ServerEvent::ClientDisconnect(old_entity)); + let _ = old_client.send(ServerGeneral::Disconnect( + DisconnectReason::Kicked(String::from( + "You have logged in from another location.", + )), + )); + // We can't login the new client right now as the + // removal of the old client and player occurs later in + // the tick, so we instead setup the new login to be + // processed in the next tick + // Create "fake" successful pending auth and mark it to + // be inserted into pending_logins at the end of this + // run + retries.push(( + entity, + PendingLogin::new_success(username.to_string(), uuid), + )); } return Ok(()); }, diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index af82105301..f6d147177d 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -148,9 +148,6 @@ impl PlayState for MainMenuState { client::Error::ServerShutdown => { localized_strings.get("main.login.server_shut_down").into() }, - client::Error::AlreadyLoggedIn => { - localized_strings.get("main.login.already_logged_in").into() - }, client::Error::NotOnWhitelist => { localized_strings.get("main.login.not_on_whitelist").into() },