1.2.0 confirm email after registration
This commit is contained in:
@@ -466,24 +466,24 @@ def login_ajax(request):
|
||||
|
||||
|
||||
|
||||
|
||||
def send_registration_mail(data_Dict, user):
|
||||
def send_check_email_after_registration(data_Dict, user):
|
||||
|
||||
try:
|
||||
|
||||
from GeneralApp.funcs_options import get_options_by_opt_types, get_mail_send_options
|
||||
sets = get_options_by_opt_types(['domain', 'project_name'], only_vals=True)
|
||||
|
||||
subject = _('Добро пожаловать в Trip With Bonus!')
|
||||
subject = _('Trip With Bonus - Подтверждение регистрации ')
|
||||
|
||||
Dict = {
|
||||
'logo': f'{sets["domain"]}/static/img/svg/LogoMobile.svg',
|
||||
'project_name': sets['project_name'],
|
||||
'domain': sets['domain'],
|
||||
'message_title': subject,
|
||||
}
|
||||
Dict.update(data_Dict)
|
||||
|
||||
html = render_to_string('mail/m_registration.html', Dict)
|
||||
html = render_to_string('mail/m_confirm_email.html', Dict)
|
||||
from BaseModels.mailSender import admin_send_mail_by_SMTPlib
|
||||
mail_sets = get_mail_send_options()
|
||||
to = [user.email, 'web@syncsystems.net', 'sa@a3-global.com', 'sysadmin.hax@gmail.com']
|
||||
@@ -501,6 +501,9 @@ def send_registration_mail(data_Dict, user):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def registration_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
@@ -528,26 +531,29 @@ def registration_ajax(request):
|
||||
|
||||
user = User.objects.create_user(username=form.data['email'], email=form.data['email'], password=form.data['password'])
|
||||
# user = auth.authenticate(username=new_user_Dict['name'], password=new_user_Dict['pass'])
|
||||
if user:
|
||||
auth.login(request, user, backend='django.contrib.auth.backends.ModelBackend')
|
||||
# if user:
|
||||
# auth.login(request, user, backend='django.contrib.auth.backends.ModelBackend')
|
||||
|
||||
if 'mailingSubscribeRequired' in data and data['mailingSubscribeRequired'] == 'true':
|
||||
user.user_profile.mailing_on = True
|
||||
|
||||
user.last_name = form.data['lastname']
|
||||
user.first_name = form.data['firstname']
|
||||
user.is_active = False
|
||||
user.save()
|
||||
user.user_profile.phone = form.data['tel']
|
||||
user.user_profile.authMailCode = uuid1().hex
|
||||
user.user_profile.save()
|
||||
|
||||
mail_Dict = {
|
||||
'user': user,
|
||||
'pass': form.data['password']
|
||||
}
|
||||
res = send_registration_mail(mail_Dict, user)
|
||||
|
||||
res = send_check_email_after_registration(mail_Dict, user)
|
||||
# res = send_registration_mail(mail_Dict, user)
|
||||
|
||||
res_Dict = {
|
||||
'redirect_url': reverse('profile_page', args=['dashboard'])
|
||||
# 'redirect_url': reverse('profile_page', args=['dashboard'])
|
||||
}
|
||||
|
||||
return JsonResponse(res_Dict)
|
||||
|
||||
@@ -46,9 +46,9 @@ urlpatterns = [
|
||||
#
|
||||
# # -----------------------
|
||||
#
|
||||
# url(r'^check_user_registration_and_activate/(?P<user_id>[\d+]*)/(?P<authCode>[0-9a-z\+\-\_]+)$',
|
||||
# check_user_registration_and_activate,
|
||||
# name='check_user_registration_and_activate'),
|
||||
path('check_user_registration_and_activate/<int:user_id>/<str:authMailCode>/',
|
||||
check_user_registration_and_activate,
|
||||
name='check_user_registration_and_activate'),
|
||||
#
|
||||
# # url(r'^user/password/reset/$',
|
||||
# # 'django.contrib.auth.views.password_reset',
|
||||
|
||||
@@ -5,7 +5,8 @@ from django.shortcuts import render
|
||||
from uuid import uuid1
|
||||
from AuthApp.models import *
|
||||
from django.contrib import auth
|
||||
from django.http import HttpResponse, Http404
|
||||
from django.urls import reverse
|
||||
from django.http import HttpResponse, Http404, HttpResponseRedirect
|
||||
from django.template import loader, RequestContext
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from BaseModels.mailSender import techSendMail
|
||||
@@ -16,6 +17,58 @@ from .funcs import *
|
||||
from GeneralApp.funcs import get_inter_http_respose
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
|
||||
|
||||
def send_registration_mail(user):
|
||||
|
||||
try:
|
||||
|
||||
from GeneralApp.funcs_options import get_options_by_opt_types, get_mail_send_options
|
||||
sets = get_options_by_opt_types(['domain', 'project_name'], only_vals=True)
|
||||
|
||||
subject = _('Добро пожаловать в Trip With Bonus!')
|
||||
|
||||
Dict = {
|
||||
'logo': f'{sets["domain"]}/static/img/svg/LogoMobile.svg',
|
||||
'project_name': sets['project_name'],
|
||||
'message_title': subject,
|
||||
'user': user
|
||||
}
|
||||
|
||||
html = render_to_string('mail/m_registration.html', Dict)
|
||||
from BaseModels.mailSender import admin_send_mail_by_SMTPlib
|
||||
mail_sets = get_mail_send_options()
|
||||
to = [user.email, 'web@syncsystems.net', 'sa@a3-global.com', 'sysadmin.hax@gmail.com']
|
||||
res = admin_send_mail_by_SMTPlib(
|
||||
mail_sets,
|
||||
subject=subject,
|
||||
from_email=mail_sets['sender_email'], to=to,
|
||||
html_content=html
|
||||
)
|
||||
|
||||
return res
|
||||
except Exception as e:
|
||||
print(f'send_registration_mail Error = {str(e)}')
|
||||
return None
|
||||
|
||||
def check_user_registration_and_activate(request, user_id, authMailCode):
|
||||
try:
|
||||
user = User.objects.get(
|
||||
id=user_id,
|
||||
is_active=False,
|
||||
user_profile__authMailCode=authMailCode
|
||||
)
|
||||
user.is_active = True
|
||||
user.save(update_fields=['is_active'])
|
||||
|
||||
res = send_registration_mail(user)
|
||||
|
||||
return HttpResponseRedirect(reverse('login_profile'))
|
||||
except User.DoesNotExist:
|
||||
user = None
|
||||
|
||||
raise Http404
|
||||
|
||||
|
||||
def registration_View(request):
|
||||
|
||||
Dict = {}
|
||||
|
||||
Reference in New Issue
Block a user