mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-09-12 20:42:29 +00:00
Enforce username regex
This commit is contained in:
parent
7e7498d368
commit
de6f624271
1 changed files with 5 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
|
@ -51,6 +52,10 @@ public class Database : DbContext
|
|||
// 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");
|
||||
|
||||
Regex regex = new("^[a-zA-Z0-9_.-]*$");
|
||||
|
||||
if (!regex.IsMatch(username)) throw new ArgumentException(nameof(username) + " does not match the username regex");
|
||||
|
||||
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