Skip to content

Commit cf07157

Browse files
committed
Merge branch 'feature/rework-email-tokens' of github.com:caravancoop/rest-framework-auth-toolkit into feature/rework-email-tokens
2 parents e248ad9 + 4eced47 commit cf07157

File tree

17 files changed

+154
-86
lines changed

17 files changed

+154
-86
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
- restore_cache:
2727
keys:
2828
- rest-auth-toolkit-py37-v6-{{ arch }}-{{ checksum "requirements-test.txt" }}-{{ checksum "demo/requirements.txt" }}
29-
- rest-auth-toolkit-py37-v5-{{ arch }}-{{ checksum "requirements-test.txt" }}-{{ checksum "demo/requirements.txt" }}
3029
- rest-auth-toolkit-py37-v6-{{ arch }}-{{ checksum "requirements-test.txt" }}
3130
- rest-auth-toolkit-py37-v6-{{ arch }}-
3231
- run:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{% load i18n %}
2+
<!doctype html>
3+
<html>
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
</head>
8+
<body style="background-color: #F7F8FA;">
9+
<div>
10+
11+
<p>
12+
{% trans "Follow this link to validate your email:" %}<br>
13+
{% url "pages:confirm-email" token=confirmation.external_id as confirmation_url %}
14+
<a href="{{ base_url }}{{ confirmation_url }}">{{ base_url }}{{ confirmation_url }}</a>
15+
</p>
16+
17+
<p>
18+
{% trans "Or send an API request to simulate a front-end application:" %}<br>
19+
<code>HTTP POST {% url "auth:confirm" %} token="{{ confirmation.external_id }}"</code>
20+
</p>
21+
22+
</div>
23+
</body>
24+
</html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% autoescape off %}
2+
{% load i18n %}
3+
4+
{% trans "Follow this link to validate your email:" %}
5+
{{ base_url }}{% url "pages:confirm-email" token=confirmation.external_id %}
6+
7+
{% trans "Or send an API request to simulate a front-end application:" %}
8+
HTTP POST {% url "auth:confirm" %} token="{{ confirmation.external_id }}"
9+
10+
{% endautoescape %}

demo/demo/pages/auth_urls.py

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% load i18n %}
2+
{% get_current_language as LANGUAGE_CODE %}
3+
<!doctype html>
4+
<html lang="{{ LANGUAGE_CODE }}">
5+
<head>
6+
<meta charset="utf-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<title>{% block title %}{% endblock %}</title>
9+
</head>
10+
<body>
11+
{% block body %}{% endblock %}
12+
</body>
13+
</html>
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1+
{% extends "base.html" %}
12
{% load i18n %}
2-
{% get_current_language as LANGUAGE_CODE %}
3-
<!doctype html>
4-
<html lang="{{ LANGUAGE_CODE }}">
5-
<head>
6-
<meta charset="utf-8">
7-
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
<title>{{ site_name }}</title>
9-
</head>
10-
<body>
3+
{% block title %}Error! {{ site_name }}{% endblock %}
114

5+
{% block body %}
126
<div>
137
<h1>{% trans "Error!" %}</h1>
148
<p>{{ error }}</p>
159
</div>
16-
17-
</body>
18-
</html>
10+
{% endblock %}

demo/demo/pages/templates/index.html

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
{% load i18n %}
2-
{% get_current_language as LANGUAGE_CODE %}
3-
<!doctype html>
4-
<html lang="{{ LANGUAGE_CODE }}">
5-
<head>
6-
<meta charset="utf-8">
7-
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
<title>{{ site_name }}</title>
9-
</head>
10-
<body>
1+
{% extends "base.html" %}
2+
{% block title %}{{ site_name }}{% endblock %}
3+
4+
{% block body %}
115
<script>
126
window.fbAsyncInit = function() {
137
FB.init({appId: "{{ fb_app_id }}", xfbml: true, version: "v2.9"});
@@ -34,12 +28,11 @@
3428
<div id="fb-root"></div>
3529

3630
<div>
37-
<h1>Hello!</h1>
31+
<h1>Hello world!</h1>
3832
<button onclick="fb_login()">Login with Facebook</button>
3933
</div>
4034

4135
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
4236
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
4337
crossorigin="anonymous"></script>
44-
</body>
45-
</html>
38+
{% endblock %}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% extends "base.html" %}
2+
{% load i18n %}
3+
{% block title %}Success! {{ site_name }}{% endblock %}
4+
5+
{% block body %}
6+
<div>
7+
<h1>{% trans "Success!" %}</h1>
8+
<p>Your address {{ email }} is now confirmed.</p>
9+
</div>
10+
{% endblock %}

demo/demo/pages/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88

99
urlpatterns = [
1010
url(r'^$', views.index, name='root'),
11+
url(r'^welcome/(?P<token>[^/.]+)$', views.confirm_email, name='confirm-email'),
1112
]

demo/demo/pages/views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ def index(request):
1414
return render(request, 'index.html', context=ctx)
1515

1616

17-
def email_view(request, external_id):
17+
def confirm_email(request, token):
1818
"""Landing page for links in confirmation emails."""
1919
error = None
2020

2121
try:
22-
confirmation = EmailConfirmation.objects.get(external_id=external_id)
22+
confirmation = EmailConfirmation.objects.get(external_id=token)
2323
confirmation.confirm()
2424
except EmailConfirmation.DoesNotExist:
2525
error = _('Invalid link')
@@ -33,4 +33,8 @@ def email_view(request, external_id):
3333
}
3434
return render(request, 'error.html', context=ctx)
3535
else:
36-
return index(request)
36+
ctx = {
37+
'site_name': 'Demo',
38+
'email': confirmation.user.email,
39+
}
40+
return render(request, 'welcome.html', context=ctx)

0 commit comments

Comments
 (0)