|
|
|
|
@ -1,8 +1,20 @@ |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
|
|
|
from accounts.models import User |
|
|
|
|
import random |
|
|
|
|
import string |
|
|
|
|
|
|
|
|
|
from accounts.models import User |
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.contrib.sites.models import RequestSite, Site |
|
|
|
|
from django.core import signing |
|
|
|
|
from django.core.mail import EmailMultiAlternatives |
|
|
|
|
from django.core.urlresolvers import reverse |
|
|
|
|
from django.shortcuts import redirect |
|
|
|
|
from registration import signals |
|
|
|
|
from registration.models import RegistrationProfile |
|
|
|
|
from social.pipeline.partial import partial |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_pass(): |
|
|
|
|
digits = random.sample(('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'), 4) |
|
|
|
|
chars = random.sample(string.lowercase[:], 4) |
|
|
|
|
@ -19,9 +31,6 @@ def load_user(strategy, details, response, uid, *args, **kwargs): |
|
|
|
|
|
|
|
|
|
return {'user': user, 'is_new': False} |
|
|
|
|
|
|
|
|
|
from django.contrib.sites.models import Site, RequestSite |
|
|
|
|
from registration.models import RegistrationProfile |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_user(strategy, details, response, uid, user=None, *args, **kwargs): |
|
|
|
|
if user: |
|
|
|
|
@ -39,33 +48,20 @@ def create_user(strategy, details, response, uid, user=None, *args, **kwargs): |
|
|
|
|
return {'user': new_user, 'is_new': True} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from django.shortcuts import redirect |
|
|
|
|
from social.pipeline.partial import partial |
|
|
|
|
from registration import signals |
|
|
|
|
|
|
|
|
|
@partial |
|
|
|
|
def require_email(strategy, details, user=None, is_new=False, *args, **kwargs): |
|
|
|
|
if user and user.email: |
|
|
|
|
return |
|
|
|
|
elif is_new and not details.get('email'): |
|
|
|
|
email = strategy.request_data().get('email') |
|
|
|
|
if email: |
|
|
|
|
if email and not User.objects.filter(email=email).exists(): |
|
|
|
|
details['email'] = email |
|
|
|
|
else: |
|
|
|
|
strategy.request.session['new_email'] = True |
|
|
|
|
strategy.request.session['new_email_invalid'] = True |
|
|
|
|
return redirect('acquire_email') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from django.core import signing |
|
|
|
|
from django.core.mail import EmailMultiAlternatives |
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.core.urlresolvers import reverse |
|
|
|
|
|
|
|
|
|
def SendVerificationEmail(strategy, backend, code): |
|
|
|
|
""" |
|
|
|
|
Send an email with an embedded verification code and the necessary details to restore the required session |
|
|
|
|
@ -94,4 +90,4 @@ Please click on <a href='{verifyURL}'>this link</a> to continue registration. |
|
|
|
|
|
|
|
|
|
email = EmailMultiAlternatives(**kwargs) |
|
|
|
|
email.attach_alternative(emailHTML, "text/html") |
|
|
|
|
email.send() |
|
|
|
|
email.send() |
|
|
|
|
|