Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-gray-tangent committed Jul 19, 2024
1 parent 8586b92 commit a569184
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 46 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ EMAIL_HOST_USER=''
EMAIL_HOST_PASSWORD=''
EMAIL_BACKEND_CONSOLE='True/False'
EMAIL_USE_TLS=True
DEFAULT_FROM_EMAIL='[email protected]'
5 changes: 1 addition & 4 deletions app/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
PasswordResetForm,
UserCreationForm,
)
from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _

from users.models import CustomUser
Expand Down Expand Up @@ -48,11 +47,9 @@ def __init__(self, *args, **kwargs):
field.widget.attrs.update({"class": "form-control"})


User = get_user_model()


class CustomPasswordResetForm(PasswordResetForm):
def clean_email(self):
User = get_user_model()
email = self.cleaned_data["email"]
users = User.objects.filter(email=email)
if not users.exists():
Expand Down
1 change: 1 addition & 0 deletions app/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,4 @@ class CustomPasswordResetView(PasswordResetView):
form_class = CustomPasswordResetForm
template_name = "accounts/password_reset_form.html"
success_url = "/accounts/password_reset/done/"
html_email_template_name = "registration/password_reset_email.html"
72 changes: 30 additions & 42 deletions app/templates/registration/password_reset_email.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Password Reset</title>
<style>
body {
Expand All @@ -16,65 +17,52 @@
margin: 0 auto;
background-color: #ffffff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border: 1px solid #dddddd;
}

.header {
background-color: #4CAF50;
color: white;
padding: 10px 0;
text-align: center;
border-radius: 10px 10px 0 0;
h1 {
color: #333333;
}

.content {
margin: 20px 0;
p {
color: #666666;
}

.content p {
line-height: 1.6;
color: #333333;
a {
color: #1a73e8;
text-decoration: none;
}

.button {
display: inline-block;
padding: 10px 20px;
margin: 20px 0;
color: white;
background-color: #4CAF50;
text-decoration: none;
background-color: #1a73e8;
color: #ffffff;
text-align: center;
border-radius: 5px;
text-decoration: none;
}

.footer {
text-align: center;
color: #777777;
font-size: 12px;
margin-top: 20px;
.button:hover {
background-color: #1558b0;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Password Reset</h1>
</div>
<div class="content">
<p>Hello {{ user.get_username }},</p>
<p>You requested a password reset. Click the button below to reset your password:</p>
<p>
<a href="{{ protocol }}://{{ domain }}{% url 'accounts:password_reset_confirm' uidb64=uid token=token %}"
style="display: inline-block; padding: 10px 20px; margin: 20px 0; color: white; background-color: #4CAF50; text-decoration: none; border-radius: 5px;">Reset
my password</a>
</p>
<p>If you didn't request this, please ignore this email.</p>
<p>Thanks,</p>
<p>Your website team</p>
</div>
<div class="footer">
<p>&copy; 2024 Your Website. All rights reserved.</p>
</div>
<h1>Password Reset</h1>

<p>Hello {{ user.get_username }},</p>
<p>You requested a password reset. Click the button below to reset your password:</p>
<p>
<a href="{{ protocol }}://{{ domain }}{% url 'accounts:password_reset_confirm' uidb64=uid token=token %}"
class="button">
Reset my password
</a>
</p>
<p>If you didn't request this, please ignore this email.</p>
<p>Thanks,</p>
<p>Your website team</p>
</div>
</body>
</html>
</html>

0 comments on commit a569184

Please sign in to comment.