Skip to content

Commit e1ee3d7

Browse files
Adjusted password strength regex to allow forward slashes
1 parent 26073b4 commit e1ee3d7

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

templates/authentication/register.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<div class="mb-3">
2626
<label for="password" class="form-label">Password</label>
2727
<input type="password" class="form-control" id="password" name="password"
28-
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@$!%*?&\{\}\<\>\.\,\\\\'#\-_=\+\(\)\[\]:;\|~])[A-Za-z\d@$!%*?&\{\}\<\>\.\,\\\\'#\-_=\+\(\)\[\]:;\|~]{8,}"
28+
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@$!%*?&\{\}\<\>\.\,\\\\'#\-_=\+\(\)\[\]:;\|~\/])[A-Za-z\d@$!%*?&\{\}\<\>\.\,\\\\'#\-_=\+\(\)\[\]:;\|~\/]{8,}"
2929
title="Must contain at least one number, one uppercase and lowercase letter, one special character, and at least 8 or more characters"
3030
placeholder="Enter your password" required
3131
autocomplete="new-password">

utils/auth.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from datetime import UTC, datetime, timedelta
1313
from typing import Optional
1414
from fastapi import Depends, Cookie, HTTPException, status
15-
from fastapi.responses import RedirectResponse
1615
from utils.db import get_session
1716
from utils.models import User, PasswordResetToken
1817

@@ -76,7 +75,7 @@ def validate_password_strength(v: str) -> str:
7675
"""
7776
logger.debug(f"Validating password for {field_name}")
7877
pattern = re.compile(
79-
r"(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@$!%*?&{}<>.,\\'#\-_=+\(\)\[\]:;|~])[A-Za-z\d@$!%*?&{}<>.,\\'#\-_=+\(\)\[\]:;|~]{8,}")
78+
r"(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@$!%*?&{}<>.,\\'#\-_=+\(\)\[\]:;|~/])[A-Za-z\d@$!%*?&{}<>.,\\'#\-_=+\(\)\[\]:;|~/]{8,}")
8079
if not pattern.match(v):
8180
logger.debug(f"Password for {
8281
field_name} does not satisfy the security policy")

0 commit comments

Comments
 (0)