-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Reset Password Feature * Remove unnecessary code * Update some mail configurations * Added reset time to be 1 day
- Loading branch information
1 parent
2878737
commit 59db559
Showing
11 changed files
with
204 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,6 +167,10 @@ | |
AUTHENTICATION_BACKENDS = [ | ||
"accounts.backend.CorpusAuthBackend", | ||
] | ||
|
||
# Reset Timeout in seconds. 1 day | ||
PASSWORD_RESET_TIMEOUT = 86400 | ||
|
||
LOGIN_URL = "/accounts/login" | ||
LOGIN_REDIRECT_URL = "/" | ||
LOGOUT_URL = "" | ||
|
@@ -175,7 +179,9 @@ | |
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") | ||
|
||
# Email Settings | ||
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" | ||
EMAIL_PROTOCOL = os.getenv("EMAIL_PROTOCOL", "console") | ||
|
||
EMAIL_BACKEND = f"django.core.mail.backends.{EMAIL_PROTOCOL}.EmailBackend" | ||
EMAIL_HOST = os.environ.get("EMAIL_HOST", "smtp.gmail.com") | ||
EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER", "[email protected]") | ||
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD", "gmailapppassword") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
corpus/templates/registration/password_reset_complete.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block title %} | ||
Complete! | Reset Password | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="card w-3/4 lg:w-1/3 mx-auto my-10 bg-base-200 shadow-xl"> | ||
<div class="card-body"> | ||
<h1 class="card-title text-2xl">Complete!</h1> | ||
<p> | ||
Your password has been reset. | ||
Please continue to | ||
<a href="{% url 'accounts_signin' %}" class="underline underline-offset-2"> | ||
login | ||
</a> | ||
to access your account. | ||
</p> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block title %} | ||
Reset Password | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="card w-3/4 lg:w-1/3 mx-auto my-10 bg-base-200 shadow-xl"> | ||
<div class="card-body"> | ||
{% if validlink %} | ||
<h1 class="card-title text-2xl">Reset Password</h1> | ||
<form method="post"> | ||
{% csrf_token %} | ||
|
||
{% if form.non_field_errors %} | ||
{% for error in form.non_field_errors %} | ||
<div role="alert" class="alert alert-error mt-1"> | ||
<span>{{ error }}</span> | ||
</div> | ||
{% endfor %} | ||
{% endif %} | ||
|
||
<div class="w-full my-2"> | ||
<label for="{{ form.new_password1.id_for_label }}">New Password</label> | ||
{{ form.new_password1 }} | ||
{% if form.new_password1.errors %} | ||
<div class="my-1"> | ||
<div role="alert" class="alert alert-error"> | ||
{{ form.new_password1.errors }} | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
<div class="w-full my-2"> | ||
<label for="{{ form.new_password2.id_for_label }}">Confirm New Password</label> | ||
{{ form.new_password2 }} | ||
{% if form.new_password2.errors %} | ||
<div class="my-1"> | ||
<div role="alert" class="alert alert-error"> | ||
{{ form.new_password2.errors }} | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
<div class="card-actions mt-5"> | ||
<button type="submit" class="btn btn-primary btn-block">Reset Password</button> | ||
</div> | ||
</form> | ||
{% else %} | ||
<h1 class="card-title text-2xl">Invalid Link</h1> | ||
<p> | ||
The password reset link was invalid, possibly because it has already been used. | ||
Please request a new password reset link. | ||
</p> | ||
{% endif %} | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block title %} | ||
Done! | Reset Password | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="card w-3/4 lg:w-1/3 mx-auto my-10 bg-base-200 shadow-xl"> | ||
<div class="card-body"> | ||
<h1 class="card-title text-2xl">Reset Password</h1> | ||
<p> | ||
We've emailed you instructions for setting your password, if an account exists with the email you | ||
entered. You should receive them shortly. The reset link is valid for <strong>1 day</strong>. | ||
</p> | ||
<p> | ||
If you don't receive an email, please make sure you've entered the address you registered with, and | ||
check your spam folder. | ||
</p> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{% extends 'emails/base.html' %} | ||
|
||
{% block title %} | ||
Reset Password | Corpus | IEEE NITK | ||
{% endblock %} | ||
|
||
{% block content %} | ||
{% autoescape off %} | ||
<p> | ||
To initiate the password reset process for your {{ user.get_username }} Corpus Account, | ||
click the link below: | ||
</p> | ||
|
||
<p> | ||
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} | ||
</p> | ||
|
||
<p> | ||
If clicking the link above doesn't work, please copy and paste the URL in a new browser window instead. | ||
</p> | ||
<p> | ||
The link will be accessible for the next <strong>1 day</strong>. | ||
</p> | ||
|
||
<p> | ||
Sincerely, | ||
<br> | ||
IEEE NITK | ||
</p> | ||
{% endautoescape %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block title %} | ||
Reset Password | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="card w-3/4 lg:w-1/3 mx-auto my-10 bg-base-200 shadow-xl"> | ||
<div class="card-body"> | ||
<h1 class="card-title text-2xl">Reset Password</h1> | ||
|
||
<form method="post"> | ||
{% csrf_token %} | ||
|
||
{% if form.non_field_errors %} | ||
{% for error in form.non_field_errors %} | ||
<div role="alert" class="alert alert-error mt-1"> | ||
<span>{{ error }}</span> | ||
</div> | ||
{% endfor %} | ||
{% endif %} | ||
|
||
<div class="w-full my-2"> | ||
<label for="{{ form.email.id_for_label }}">Email</label> | ||
{{ form.email }} | ||
{% if form.email.errors %} | ||
<div class="my-1"> | ||
<div role="alert" class="alert alert-error"> | ||
{{ form.email.errors }} | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
<div class="card-actions mt-5"> | ||
<button type="submit" class="btn btn-primary btn-block">Send me a reset link</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Reset Password | Corpus | IEEE NITK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ services: | |
- .env | ||
environment: | ||
- ENVIRONMENT=PRODUCTION | ||
- EMAIL_PROTOCOL=smtp | ||
|
||
nginx: | ||
build: nginx | ||
|