From 296a4c3383857bb2829fdb84a5d806ef6ed25c27 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Thu, 1 Feb 2018 09:55:18 +0300 Subject: [PATCH] Add success verification view --- apps/auth/urls.py | 1 + apps/auth/views.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/auth/urls.py b/apps/auth/urls.py index e4278014..8adfed45 100644 --- a/apps/auth/urls.py +++ b/apps/auth/urls.py @@ -7,6 +7,7 @@ urlpatterns = [ path('logout/', views.LogoutView.as_view(), name="logout"), path('login/', views.LoginView.as_view(), name="login"), path('verification-email//', views.VerificationEmailView.as_view(), name="verification-email"), + path('success-verification-email/', views.SuccessVerificationEmailView.as_view(), name="success-verification-email"), path('facebook_login/', views.FacebookLoginOrRegistration.as_view(), name="facebook_login"), path('password_reset/', views.PasswordResetView.as_view(), name="password_reset"), diff --git a/apps/auth/views.py b/apps/auth/views.py index 9dccdbe9..0c0d248c 100644 --- a/apps/auth/views.py +++ b/apps/auth/views.py @@ -9,7 +9,7 @@ from django.http import JsonResponse from django.urls import reverse_lazy from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt -from django.views.generic import FormView, View +from django.views.generic import FormView, View, TemplateView from django.views.generic.edit import BaseFormView from django.shortcuts import redirect @@ -83,11 +83,16 @@ class VerificationEmailView(View): if is_valid_token: request.user.is_email_proved = True request.user.save() - return JsonResponse({"success": True}) + login(request, request.user) + return redirect(reverse_lazy('lilcity:success-verification-email')) else: return JsonResponse({"success": False}, status=400) +class SuccessVerificationEmailView(TemplateView): + template_name = 'auth/success-verification.html' + + class PasswordResetView(views.PasswordContextMixin, BaseFormView): email_template_name = "auth/password_reset.html" subject_template_name = "auth/password_reset_subject.txt"