From b21b43e43004ef7083c895787ff414e07d4ad2ef Mon Sep 17 00:00:00 2001 From: Goober5000 Date: Sat, 23 Aug 2025 18:50:18 -0400 Subject: [PATCH] trim spaces from usernames and related nebula info Usernames with extra spaces will show up as unrecognized, both in login and when adding members to a mod, so this is an attempt to properly handle that situation. --- Knossos.NET/Models/ModMember.cs | 8 +++++++- .../ViewModels/Templates/NebulaLoginViewModel.cs | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Knossos.NET/Models/ModMember.cs b/Knossos.NET/Models/ModMember.cs index 707844c2..8ee5bd96 100644 --- a/Knossos.NET/Models/ModMember.cs +++ b/Knossos.NET/Models/ModMember.cs @@ -20,7 +20,13 @@ public enum ModMemberRole public class ModMember { + private string _user = string.Empty; + public ModMemberRole role { get; set; } - public string user { get; set; } = string.Empty; + public string user + { + get { return _user; } + set { _user = value.Trim(); } + } } } diff --git a/Knossos.NET/ViewModels/Templates/NebulaLoginViewModel.cs b/Knossos.NET/ViewModels/Templates/NebulaLoginViewModel.cs index 52ebc85b..0a69cde1 100644 --- a/Knossos.NET/ViewModels/Templates/NebulaLoginViewModel.cs +++ b/Knossos.NET/ViewModels/Templates/NebulaLoginViewModel.cs @@ -97,7 +97,10 @@ internal async void Install() internal async void LogIn() { - if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPass) || string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(UserPass)) + UserName = UserName?.Trim(); + UserPass = UserPass?.Trim(); + + if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPass)) { await MessageBox.Show(MainWindow.instance!, "Username and password are required fields.", "Login error", MessageBox.MessageBoxButtons.OK); return; @@ -134,8 +137,11 @@ internal void SwitchToLogin() internal async void Register() { - if(string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPass) || string.IsNullOrEmpty(UserEmail) || - string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(UserPass) || string.IsNullOrWhiteSpace(UserEmail)) + UserName = UserName?.Trim(); + UserPass = UserPass?.Trim(); + UserEmail = UserEmail.Trim(); + + if(string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPass) || string.IsNullOrEmpty(UserEmail)) { await MessageBox.Show(MainWindow.instance!, "Username, password and email are all required fields.", "Register error", MessageBox.MessageBoxButtons.OK); return; @@ -165,7 +171,9 @@ internal async void Register() internal async void Reset() { - if (string.IsNullOrEmpty(UserName) || string.IsNullOrWhiteSpace(UserName)) + UserName = UserName?.Trim(); + + if (string.IsNullOrEmpty(UserName)) { await MessageBox.Show(MainWindow.instance!, "Username is a required field.", "Reset password", MessageBox.MessageBoxButtons.OK); return;