1.2.0 confirm email after registration

This commit is contained in:
SDE
2024-06-09 16:37:08 +03:00
parent 3a235b4f60
commit 74e76fe6e7
4 changed files with 159 additions and 13 deletions

View File

@@ -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 = {}