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