Skip to content
Snippets Groups Projects
Commit 2b53c3de authored by Chris Li's avatar Chris Li
Browse files

Enable email sending function.

parent 7a191d0f
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ def send_activation_email(sender, instance, created, *args, **kwargs): ...@@ -25,7 +25,7 @@ def send_activation_email(sender, instance, created, *args, **kwargs):
'current_user': instance, 'current_user': instance,
'username': instance.username, 'username': instance.username,
'email': instance.email, 'email': instance.email,
'domain': 'localhost:8000', 'domain': 'hamsterwhat.com',
'token': AuthToken.objects.create(instance)[0].digest 'token': AuthToken.objects.create(instance)[0].digest
} }
...@@ -34,11 +34,11 @@ def send_activation_email(sender, instance, created, *args, **kwargs): ...@@ -34,11 +34,11 @@ def send_activation_email(sender, instance, created, *args, **kwargs):
msg = EmailMessage( msg = EmailMessage(
# title: # title:
"User Verification for {title}".format(title="Some website title"), "User Verification for {title}".format(title="HamsterWhat"),
# message: # message:
email_html_message, email_html_message,
# from: # from:
"noreply@somehost.local", "hamsterwhat@gmail.com",
# to: # to:
[instance.email] [instance.email]
) )
...@@ -61,11 +61,11 @@ def password_reset_token_created(sender, instance, reset_password_token, *args, ...@@ -61,11 +61,11 @@ def password_reset_token_created(sender, instance, reset_password_token, *args,
msg = EmailMessage( msg = EmailMessage(
# title: # title:
"Password Reset for {title}".format(title="Some website title"), "Password Reset for {title}".format(title="HamsterWhat"),
# message: # message:
email_html_message, email_html_message,
# from: # from:
"noreply@somehost.local", "hamsterwhat@gmail.com",
# to: # to:
[reset_password_token.user.email] [reset_password_token.user.email]
) )
......
...@@ -54,8 +54,8 @@ REST_FRAMEWORK = { ...@@ -54,8 +54,8 @@ REST_FRAMEWORK = {
} }
REST_KNOX = { REST_KNOX = {
'TOKEN_TTL': timedelta(days=7), 'TOKEN_TTL': timedelta(days=7),
'AUTO_REFRESH': True, 'AUTO_REFRESH': True,
} }
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -130,13 +130,20 @@ TIME_ZONE = 'America/Toronto' ...@@ -130,13 +130,20 @@ TIME_ZONE = 'America/Toronto'
USE_I18N = True USE_I18N = True
USE_TZ = False USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/ # https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = 'static/' STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
STATICFILES_DIRS = (
("js", os.path.join(STATIC_ROOT, 'js')),
("css", os.path.join(STATIC_ROOT, 'css')),
("images", os.path.join(STATIC_ROOT, 'images')),
("fonts", os.path.join(STATIC_ROOT, 'fonts')),
)
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
...@@ -144,8 +151,13 @@ STATIC_URL = 'static/' ...@@ -144,8 +151,13 @@ STATIC_URL = 'static/'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Email settings # Email settings
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'hamsterwhat@gmail.com'
EMAIL_HOST_PASSWORD = 'psqytbyafqujeiji'
# Media Settings # Media Settings
MEDIA_URL = 'media/' MEDIA_URL = 'media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
...@@ -11,10 +11,9 @@ urlpatterns = router.urls ...@@ -11,10 +11,9 @@ urlpatterns = router.urls
urlpatterns += [ urlpatterns += [
path('', include('core.urls')), path('', include('core.urls')),
# path('dj-rest-auth/', include('dj_rest_auth.urls')),
# path('dj-rest-auth/registration/', include('dj_rest_auth.registration.urls')),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('docs/', include_docs_urls(title='ECE651 Backend API Document', description='This API document includes all ednpoints that has been implemented.')), path('docs/', include_docs_urls(title='ECE651 Backend API Document', description='This API document includes all ednpoints that has been implemented.')),
] ]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static('media/', document_root=settings.MEDIA_ROOT) urlpatterns += static('media/', document_root=settings.MEDIA_ROOT)
{% autoescape off %} {% autoescape off %}
To initiate the password reset process for you {{ username }} for your BuyforFree Account, Dear {{ username }},
click the link below:
We received a request to reset the password for your account on HamsterWhat. If you did not make this request, please ignore this email.
To reset your password, please click on the link below:
{{reset_password_url}} {{reset_password_url}}
If clicking the link above doesn't work, please copy and paste the URL in a new browser If you have any issues with the password reset process, please don't hesitate to contact our support team at hamsterwhat@gmail.com and we'll be happy to assist you.
window instead.
Sincerely, Best regards,
ECE651_DEMO HamsterWhat Team
{% endautoescape %} {% endautoescape %}
\ No newline at end of file
{% autoescape off %} {% autoescape off %}
To initiate the password reset process for you {{ username }} for your Account, Dear {{ username }},
click the link below:
http://{{ domain }}{% url 'activate' token=token %} Thank you for signing up with HamsterWhat! We're excited to have you onboard.
If clicking the link above doesn't work, please copy and paste the URL in a new browser Before you can start using your account, we need to verify your email address and activate your account. Please follow the instructions below to complete the activation process:
window instead.
Sincerely, 1. Click on the activation link below:
ECE651_DEMO https://{{ domain }}{% url 'activate' token=token %}
2. Once you click the link, you will be taken to our website where you can receive a notice about whether you have successfully verified your account.
If you have any issues with the activation process, please don't hesitate to contact our support team at hamsterwhat@gmail.com and we'll be happy to assist you.
We look forward to having you as part of our community.
Best regards,
HamsterWhat Team
{% endautoescape %} {% endautoescape %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment