-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gerard Casas Saez
committed
Oct 25, 2017
1 parent
7c20aa8
commit 3749eb3
Showing
12 changed files
with
114 additions
and
3 deletions.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% if user.email_verified %} | ||
<p> | ||
Your email has been verified! | ||
|
||
</p> | ||
{% else %} | ||
Please check your inbox to verify that <b>{{ user.email }}</b> is your email. | ||
{% endif %} |
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
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,10 @@ | ||
from app import emails | ||
|
||
|
||
def create_verify_email(user, activate_url): | ||
c = { | ||
'user': user, | ||
'activate_url': activate_url | ||
} | ||
return emails.render_mail('mails/verify_email', | ||
user.email, c) |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends 'base_email.html' %} | ||
{% block preheader %}Verify your email address{% endblock %} | ||
|
||
{% block content %} | ||
{% include 'include/email_line_start.html' %} | ||
Hey {{ user.nickname }}, | ||
{% include 'include/email_line_end.html' %} | ||
{% include 'include/email_line.html' with text="You have 5 days to verify your email address for your account at "|add:h_name %} | ||
{% include 'include/email_button.html' with text='Verify' url=activate_url %} | ||
|
||
{% include 'include/email_line.html' with text="Best," %} | ||
{% include 'include/email_line.html' with text="" %} | ||
{% include 'include/email_line.html' with text=h_name|add:" Team" %} | ||
{% 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,10 @@ | ||
Hi there {{ user.nickname }}, | ||
|
||
You're receiving this e-mail because a user has given yours as an e-mail address to connect their account in {{ h_name }}. | ||
Activate your account by using the following URL: | ||
|
||
{{activate_url}} | ||
|
||
Best, | ||
|
||
{{ h_name }} Team |
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 @@ | ||
Please Confirm Your E-mail Address |
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,27 @@ | ||
from django.conf import settings | ||
from django.contrib.auth.tokens import PasswordResetTokenGenerator | ||
from django.urls import reverse | ||
from django.utils import six | ||
from django.utils.encoding import force_bytes | ||
from django.utils.http import urlsafe_base64_encode | ||
|
||
from user.emails import create_verify_email | ||
|
||
|
||
class AccountActivationTokenGenerator(PasswordResetTokenGenerator): | ||
def _make_hash_value(self, user, timestamp): | ||
return ( | ||
six.text_type(user.pk) + six.text_type(timestamp) + | ||
six.text_type(user.email_verified) | ||
) | ||
|
||
|
||
account_activation_token = AccountActivationTokenGenerator() | ||
|
||
|
||
def create_token_email(user): | ||
token = account_activation_token.make_token(user) | ||
uuid = urlsafe_base64_encode(force_bytes(user.pk)) | ||
activate_url = 'http://' + settings.HACKATHON_DOMAIN + \ | ||
reverse('activate', kwargs={'uid': uuid, 'token': token}) | ||
return create_verify_email(user, activate_url) |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from django.conf.urls import url | ||
|
||
from user import views | ||
|
||
urlpatterns = [ | ||
url(r'login/$', views.login, name='account_login'), | ||
url(r'signup/$', views.signup, name='account_signup'), | ||
url(r'logout/$', views.logout, name='account_logout'), | ||
|
||
url(r'^activate/(?P<uid>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', | ||
views.activate, name='activate'), | ||
] |
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