Skip to content

Commit 4eced47

Browse files
committed
add skeleton for email confirmation endpoint
1 parent 9590e20 commit 4eced47

File tree

5 files changed

+37
-5
lines changed

5 files changed

+37
-5
lines changed

demo/demo/accounts/templates/rest_auth_toolkit/email_confirmation.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88
<body style="background-color: #F7F8FA;">
99
<div>
1010

11-
<p>{% trans "Follow this link to validate your email:" %}<br>
12-
{% url "pages:confirm-email" token=confirmation.external_id as confirmation_url %}
13-
<a href="{{ base_url }}{{ confirmation_url }}">{{ base_url }}{{ confirmation_url }}</a></p>
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>
1421

1522
</div>
1623
</body>

demo/demo/accounts/templates/rest_auth_toolkit/email_confirmation.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
{% trans "Follow this link to validate your email:" %}
55
{{ base_url }}{% url "pages:confirm-email" token=confirmation.external_id %}
66

7+
{% trans "Or send an API request to simulate a front-end application:" %}
8+
HTTP POST {% url "auth:confirm" %} token="{{ confirmation.external_id }}"
9+
710
{% endautoescape %}

demo/demo/urls.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
from django.urls import include, path
44
from django.contrib import admin
55

6-
from rest_auth_toolkit.views import FacebookLoginView, LoginView, LogoutView, SignupView
6+
from rest_auth_toolkit.views import (
7+
EmailConfirmationView,
8+
FacebookLoginView,
9+
LoginView,
10+
LogoutView,
11+
SignupView,
12+
)
713

814

915
auth_urlpatterns = [
1016
path('signup/', SignupView.as_view(), name='signup'),
17+
path('confirm/', EmailConfirmationView.as_view(), name='confirm'),
1118
path('login/', LoginView.as_view(), name='login'),
1219
path('logout/', LogoutView.as_view(), name='logout'),
1320
path('fb-login/', FacebookLoginView.as_view(), name='fb-login'),

rest_auth_toolkit/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class RestAuthToolkitConfig(AppConfig):
55
"""Default app config for RATK.
66
77
This installs a signal handler to set user.is_active when
8-
email_confirmed is emitted.
8+
email_confirmed is emitted by EmailConfirmationView.
99
"""
1010
name = 'rest_auth_toolkit'
1111

rest_auth_toolkit/views.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ def post(self, request):
7575
return Response(status=status.HTTP_201_CREATED)
7676

7777

78+
class EmailConfirmationView(generics.GenericAPIView):
79+
"""Validate an email address after sign-up.
80+
81+
Response: 200 OK (no content)
82+
83+
Error response (code 400):
84+
85+
```json
86+
{"errors": {"token": "Error message"}}
87+
```
88+
"""
89+
def post(self, request):
90+
pass
91+
92+
7893
class LoginView(generics.GenericAPIView):
7994
"""Authenticate a user, return an API auth token if valid.
8095

0 commit comments

Comments
 (0)