Skip to content

Commit a429ee4

Browse files
authored
Merge pull request #333 from Goober5000/trim_spaces
trim spaces from usernames and related nebula info
2 parents b636f14 + b21b43e commit a429ee4

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

Knossos.NET/Models/ModMember.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ public enum ModMemberRole
2020

2121
public class ModMember
2222
{
23+
private string _user = string.Empty;
24+
2325
public ModMemberRole role { get; set; }
24-
public string user { get; set; } = string.Empty;
26+
public string user
27+
{
28+
get { return _user; }
29+
set { _user = value.Trim(); }
30+
}
2531
}
2632
}

Knossos.NET/ViewModels/Templates/NebulaLoginViewModel.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ internal async void Install()
9797

9898
internal async void LogIn()
9999
{
100-
if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPass) || string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(UserPass))
100+
UserName = UserName?.Trim();
101+
UserPass = UserPass?.Trim();
102+
103+
if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPass))
101104
{
102105
await MessageBox.Show(MainWindow.instance!, "Username and password are required fields.", "Login error", MessageBox.MessageBoxButtons.OK);
103106
return;
@@ -134,8 +137,11 @@ internal void SwitchToLogin()
134137

135138
internal async void Register()
136139
{
137-
if(string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPass) || string.IsNullOrEmpty(UserEmail) ||
138-
string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(UserPass) || string.IsNullOrWhiteSpace(UserEmail))
140+
UserName = UserName?.Trim();
141+
UserPass = UserPass?.Trim();
142+
UserEmail = UserEmail.Trim();
143+
144+
if(string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPass) || string.IsNullOrEmpty(UserEmail))
139145
{
140146
await MessageBox.Show(MainWindow.instance!, "Username, password and email are all required fields.", "Register error", MessageBox.MessageBoxButtons.OK);
141147
return;
@@ -165,7 +171,9 @@ internal async void Register()
165171

166172
internal async void Reset()
167173
{
168-
if (string.IsNullOrEmpty(UserName) || string.IsNullOrWhiteSpace(UserName))
174+
UserName = UserName?.Trim();
175+
176+
if (string.IsNullOrEmpty(UserName))
169177
{
170178
await MessageBox.Show(MainWindow.instance!, "Username is a required field.", "Reset password", MessageBox.MessageBoxButtons.OK);
171179
return;

0 commit comments

Comments
 (0)