mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 16:38:37 +00:00
Enforce 3-16 character limit on usernames
This commit is contained in:
parent
ede6e8f8e4
commit
7e7498d368
1 changed files with 4 additions and 1 deletions
|
@ -46,7 +46,10 @@ public class Database : DbContext
|
|||
|
||||
public async Task<User> CreateUser(string username, string password)
|
||||
{
|
||||
if (!password.StartsWith("$")) throw new ArgumentException(nameof(password) + " is not a BCrypt hash");
|
||||
if (!password.StartsWith('$')) throw new ArgumentException(nameof(password) + " is not a BCrypt hash");
|
||||
|
||||
// 16 is PSN max, 3 is PSN minimum
|
||||
if (username.Length > 16 || username.Length < 3) throw new ArgumentException(nameof(username) + " is either too long or too short");
|
||||
|
||||
User user;
|
||||
if ((user = await this.Users.Where(u => u.Username == username).FirstOrDefaultAsync()) != null) return user;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue