Skip to content

Commit 7198fd4

Browse files
Update password max length
On my machine, the command provided to generate a password (using python3 specifically), results in a 44 character string, while the maximum allowable character length in the model is 40, causing a conflict. This PR updates the max_legnth for all password model definitions. ``` MacBook-Pro-3:full-stack-fastapi-template michaelalvarino$ python3 -c "import secrets; print(secrets.token_urlsafe(32))" | wc -c 44 MacBook-Pro-3:full-stack-fastapi-template michaelalvarino$ python3 -c "import secrets; print(secrets.token_urlsafe(32))" | wc -c 44 MacBook-Pro-3:full-stack-fastapi-template michaelalvarino$ python3 -c "import secrets; print(secrets.token_urlsafe(32))" | wc -c 44 ```
1 parent 88c83cc commit 7198fd4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

backend/app/models.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ class UserBase(SQLModel):
1414

1515
# Properties to receive via API on creation
1616
class UserCreate(UserBase):
17-
password: str = Field(min_length=8, max_length=40)
17+
password: str = Field(min_length=8, max_length=45)
1818

1919

2020
class UserRegister(SQLModel):
2121
email: EmailStr = Field(max_length=255)
22-
password: str = Field(min_length=8, max_length=40)
22+
password: str = Field(min_length=8, max_length=45)
2323
full_name: str | None = Field(default=None, max_length=255)
2424

2525

2626
# Properties to receive via API on update, all are optional
2727
class UserUpdate(UserBase):
2828
email: EmailStr | None = Field(default=None, max_length=255) # type: ignore
29-
password: str | None = Field(default=None, min_length=8, max_length=40)
29+
password: str | None = Field(default=None, min_length=8, max_length=45)
3030

3131

3232
class UserUpdateMe(SQLModel):
@@ -35,8 +35,8 @@ class UserUpdateMe(SQLModel):
3535

3636

3737
class UpdatePassword(SQLModel):
38-
current_password: str = Field(min_length=8, max_length=40)
39-
new_password: str = Field(min_length=8, max_length=40)
38+
current_password: str = Field(min_length=8, max_length=45)
39+
new_password: str = Field(min_length=8, max_length=45)
4040

4141

4242
# Database model, database table inferred from class name
@@ -111,4 +111,4 @@ class TokenPayload(SQLModel):
111111

112112
class NewPassword(SQLModel):
113113
token: str
114-
new_password: str = Field(min_length=8, max_length=40)
114+
new_password: str = Field(min_length=8, max_length=45)

0 commit comments

Comments
 (0)