Skip to content

Commit d4bd32a

Browse files
committed
Moved out the HASHED_PASSWORD in order to be global variable, and added an error message to the UnhashedPasswordError
1 parent 71fbb2f commit d4bd32a

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

lms/models/users.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
)
99

1010

11+
HASHED_PASSWORD = re.compile(r'^pbkdf2.+?\$(?P<salt>.+?)\$(?P<password>.+)')
12+
13+
1114
def retrieve_salt(user: User) -> str:
12-
HASHED_PASSWORD = re.compile(
13-
r'^pbkdf2.+?\$(?P<salt>.+?)\$(?P<password>.+)',
14-
)
1515
password = HASHED_PASSWORD.match(user.password)
1616
try:
1717
return password.groupdict().get('salt')
1818
except AttributeError: # should never happen
19-
raise UnhashedPasswordError
19+
raise UnhashedPasswordError('Password format is invalid.')
2020

2121

2222
def auth(username: str, password: str) -> User:

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def admin_user():
178178
)
179179

180180

181-
@pytest.fixture(autouse=True, scope='session')
181+
@pytest.fixture(autouse=True, scope='function')
182182
def captured_templates():
183183
recorded = []
184184

tests/samples/config.py.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ FEATURE_FLAG_CHECK_IDENTICAL_CODE_ON = os.getenv(
1414
)
1515

1616

17-
1817
MAIL_WELCOME_MESSAGE = 'welcome-email'
1918
USERS_CSV = 'users.csv'
2019
ERRORS_CSV = 'errors.csv'

0 commit comments

Comments
 (0)