Skip to content

Commit

Permalink
fix: only the first password letter was used
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Nov 28, 2023
1 parent c2250ec commit 98e8aa9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions canaille/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def password_init_html(user):
reset_url = url_for(
"core.auth.reset",
user=user,
hash=build_hash(user.identifier, user.preferred_email, user.password[0]),
hash=build_hash(user.identifier, user.preferred_email, user.password),
title=_("Password initialization on {website_name}").format(
website_name=current_app.config.get("NAME", "Canaille")
),
Expand All @@ -105,7 +105,7 @@ def password_init_txt(user):
reset_url = url_for(
"core.auth.reset",
user=user,
hash=build_hash(user.identifier, user.preferred_email, user.password[0]),
hash=build_hash(user.identifier, user.preferred_email, user.password),
_external=True,
)

Expand All @@ -124,7 +124,7 @@ def password_reset_html(user):
reset_url = url_for(
"core.auth.reset",
user=user,
hash=build_hash(user.identifier, user.preferred_email, user.password[0]),
hash=build_hash(user.identifier, user.preferred_email, user.password),
title=_("Password reset on {website_name}").format(
website_name=current_app.config.get("NAME", "Canaille")
),
Expand All @@ -150,7 +150,7 @@ def password_reset_txt(user):
reset_url = url_for(
"core.auth.reset",
user=user,
hash=build_hash(user.identifier, user.preferred_email, user.password[0]),
hash=build_hash(user.identifier, user.preferred_email, user.password),
_external=True,
)

Expand Down
2 changes: 1 addition & 1 deletion canaille/core/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def reset(user, hash):
build_hash(
user.identifier,
email,
user.password[0] if user.has_password() else "",
user.password if user.has_password() else "",
)
for email in user.emails
}
Expand Down
4 changes: 2 additions & 2 deletions canaille/core/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def send_password_reset_mail(user, mail):
hash=build_hash(
user.identifier,
mail,
user.password[0] if user.has_password() else "",
user.password if user.has_password() else "",
),
_external=True,
)
Expand Down Expand Up @@ -85,7 +85,7 @@ def send_password_initialization_mail(user, email):
hash=build_hash(
user.identifier,
email,
user.password[0] if user.has_password() else "",
user.password if user.has_password() else "",
),
_external=True,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/core/test_password_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def test_password_reset(testclient, user):
assert not user.check_password("foobarbaz")[0]
hash = build_hash("user", user.preferred_email, user.password[0])
hash = build_hash("user", user.preferred_email, user.password)

res = testclient.get("/reset/user/" + hash, status=200)

Expand All @@ -27,7 +27,7 @@ def test_password_reset_multiple_emails(testclient, user):
user.save()

assert not user.check_password("foobarbaz")[0]
hash = build_hash("user", "[email protected]", user.password[0])
hash = build_hash("user", "[email protected]", user.password)

res = testclient.get("/reset/user/" + hash, status=200)

Expand Down Expand Up @@ -55,7 +55,7 @@ def test_password_reset_bad_link(testclient, user):


def test_password_reset_bad_password(testclient, user):
hash = build_hash("user", user.preferred_email, user.password[0])
hash = build_hash("user", user.preferred_email, user.password)

res = testclient.get("/reset/user/" + hash, status=200)

Expand Down

0 comments on commit 98e8aa9

Please sign in to comment.