mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
Merge branch 'NyaDoo/master'
This commit is contained in:
@@ -136,7 +136,7 @@ class UsernameValidator:
|
||||
|
||||
MIN_LENGTH = 3
|
||||
MAX_LENGTH = 30
|
||||
USERNAME_REGEX = re.compile(r"^[a-zA-Z0-9_-]+$")
|
||||
USERNAME_REGEX = re.compile(r"^[a-zA-Z0-9_.\-]+$")
|
||||
|
||||
@classmethod
|
||||
def validate(cls, username: str) -> tuple[bool, Optional[str]]:
|
||||
@@ -159,7 +159,7 @@ class UsernameValidator:
|
||||
return False, f"用户名长度不能超过{cls.MAX_LENGTH}个字符"
|
||||
|
||||
if not cls.USERNAME_REGEX.match(username):
|
||||
return False, "用户名只能包含字母、数字、下划线和连字符"
|
||||
return False, "用户名只能包含字母、数字、下划线、连字符和点号"
|
||||
|
||||
# 检查保留用户名
|
||||
reserved_names = [
|
||||
|
||||
@@ -320,8 +320,8 @@ class UpdateUserRequest(BaseModel):
|
||||
if v is None:
|
||||
return v
|
||||
|
||||
if not re.match(r"^[a-zA-Z0-9_-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线和连字符")
|
||||
if not re.match(r"^[a-zA-Z0-9_.\-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线、连字符和点号")
|
||||
|
||||
return v
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@ class RegisterRequest(BaseModel):
|
||||
v = v.strip()
|
||||
if not v:
|
||||
raise ValueError("用户名不能为空")
|
||||
if not re.match(r"^[a-zA-Z0-9_-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线和短横线")
|
||||
if not re.match(r"^[a-zA-Z0-9_.\-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线、连字符和点号")
|
||||
return v
|
||||
|
||||
@classmethod
|
||||
@@ -279,8 +279,8 @@ class CreateUserRequest(BaseModel):
|
||||
v = v.strip()
|
||||
if not v:
|
||||
raise ValueError("用户名不能为空")
|
||||
if not re.match(r"^[a-zA-Z0-9_-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线和短横线")
|
||||
if not re.match(r"^[a-zA-Z0-9_.\-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线、连字符和点号")
|
||||
return v
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user