@@ 378-400 (lines=23) @@ | ||
375 | return new_ver |
|
376 | except Exception as e: |
|
377 | logger.exception("Failed to send email") |
|
378 | raise ValidationError(e.message) |
|
379 | ||
380 | ||
381 | def send_email_change(request, username, old_email, verification, new_email): |
|
382 | link = "{}://{}/change_email?token={}".format(settings.SITE_PROTOCOL, request.get_host(), verification.token) |
|
383 | message = "{},\n" \ |
|
384 | "You requested to change an email from {} to {} on site {}.\n" \ |
|
385 | "To proceed click on the link {}\n" \ |
|
386 | "If you didn't request the email change someone has hijacked your account. Please change your password" \ |
|
387 | .format(old_email, new_email, username, request.get_host(), link) |
|
388 | ip_info = get_or_create_ip(get_client_ip(request), logger) |
|
389 | start_message = mark_safe( |
|
390 | "You have requested an email change on <b>Pychat</b>. After you click on the url bellow we replace email in your profile from current one ({}) to {}. If it wasn't you please change your password as soon as possible".format(old_email, new_email)) |
|
391 | context = { |
|
392 | 'username': username, |
|
393 | 'magicLink': link, |
|
394 | 'ipInfo': ip_info.info, |
|
395 | 'ip': ip_info.ip, |
|
396 | 'btnText': "CHANGE EMAIL", |
|
397 | 'timeCreated': verification.time, |
|
398 | 'greetings': start_message |
|
399 | } |
|
400 | html_message = render_to_string('token_email.html', context, context_instance=RequestContext(request)) |
|
401 | send_mail("Pychat: change email", message, request.get_host(), (old_email,), fail_silently=False, |
|
402 | html_message=html_message) |
|
403 | ||
@@ 417-429 (lines=13) @@ | ||
414 | html_message = render_to_string('change_password.html', context, context_instance=RequestContext(request)) |
|
415 | send_mail("Pychat: password change", message, request.get_host(), (email,), fail_silently=False, |
|
416 | html_message=html_message) |
|
417 | ||
418 | ||
419 | def send_email_changed(request, old_email, new_email): |
|
420 | message = "Dmail been changed for user {}".format(request.user.username) |
|
421 | ip_info = get_or_create_ip(get_client_ip(request), logger) |
|
422 | context = { |
|
423 | 'username': request.user.username, |
|
424 | 'ipInfo': ip_info.info, |
|
425 | 'ip': ip_info.ip, |
|
426 | 'timeCreated': datetime.datetime.now(), |
|
427 | 'email': new_email, |
|
428 | } |
|
429 | html_message = render_to_string('change_email.html', context, context_instance=RequestContext(request)) |
|
430 | send_mail("Pychat: email change", message, request.get_host(), (old_email,), fail_silently=False, |
|
431 | html_message=html_message) |
|
432 |