Skip to content

Commit

Permalink
Password reset mail (#85)
Browse files Browse the repository at this point in the history
* Change reset password link in Mailer to front
* Fix password reset URL in tests.py
  • Loading branch information
KwikKill authored Oct 25, 2023
1 parent 61af992 commit e0a33ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 5 additions & 9 deletions insalan/user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,12 @@ def send_password_reset(user_object: User):
"pour votre compte. Si vous êtes à l'origine de cette demande,"
"vous pouvez cliquer sur le lien suivant: "
)
+ "http://api."
+ "http://"
+ getenv("WEBSITE_HOST", "localhost")
+ reverse("reset-password")
+ "?"
+ urlencode(
{
"user": user,
"token": token,
}
),
+ "/reset-password/"
+ user
+ "/"
+ token,
None, # Django falls back to default of settings.py
[user_object.email],
fail_silently=False,
Expand Down
6 changes: 3 additions & 3 deletions insalan/user/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def test_can_reset_password(self):

match = re.search(
# "https?://[^ ]*/password-reset/ask[^ ]*",
".*https?://[^ ]*/\?user=(?P<username>[^ &]*)&token=(?P<token>[^ /]*)",
".*https?://[^ ]*/(?P<username>[^ &]*)/(?P<token>[^ /]*)",
mail.outbox[0].body,
)

Expand Down Expand Up @@ -550,7 +550,7 @@ def test_can_reset_password_only_once(self):

match = re.search(
# "https?://[^ ]*/password-reset/ask[^ ]*",
".*https?://[^ ]*/\?user=(?P<username>[^ &]*)&token=(?P<token>[^ /]*)",
".*https?://[^ ]*/(?P<username>[^ &]*)/(?P<token>[^ /]*)",
mail.outbox[0].body,
)

Expand Down Expand Up @@ -592,7 +592,7 @@ def test_password_reset_is_token_checked(self):
self.client.post("/v1/user/password-reset/ask/", data, format="json")

match = re.search(
".*https?://[^ ]*/\?user=(?P<username>[^ &]*)&token=(?P<token>[^ /]*)",
".*https?://[^ ]*/(?P<username>[^ &]*)/(?P<token>[^ /]*)",
mail.outbox[0].body,
)

Expand Down

0 comments on commit e0a33ef

Please sign in to comment.