Hi
I'm trying to implement custom email validation at the end of the pipeline with Django 1.7.4, using the same logic as for regular non-social user registrations:
- Set user.is_active to false
- Generate and send an email with an activation link
- Redirect to success page where the user is logged in but not active, so the context can display the user email that has been captured.
At the end of the pipeline I have a validate partial function that does this:
@partial
def validate(strategy, details, user=None, is_new=False, *args, **kwargs):
if user and is_new:
user.is_active = False
user.save()
username = user.username
email = user.email
salt = hashlib.sha1(str(random.random()).encode('utf-8')).hexdigest()[:5]
activation_key = hashlib.sha1(str(salt + email).encode('utf-8')).hexdigest()
key_expires = datetime.datetime.today() + datetime.timedelta(2)
new_profile = UserProfile(user=user, activation_key=activation_key, key_expires=key_expires)
new_profile.save()
email_subject = 'Account confirmation'
email_body = "Hey %s, thanks for signing up. To activate your account, click this link within 48 hours %s%s" % (username, site(strategy.request)['site_root'], reverse('users:confirm', args=[activation_key]))
send_mail(email_subject, email_body, settings.DEFAULT_FROM_EMAIL, [email], fail_silently=False)
return
return
And in settings I have this:
SOCIAL_AUTH_INACTIVE_USER_LOGIN = True
INACTIVE_USER_URL = '/signup/success/'
The INACTIVE_USER_URL is being picked up, but the user is not logged in.
Any idea why this wouldn't work as expected?
Thanks!
Russell.
Hi
I'm trying to implement custom email validation at the end of the pipeline with Django 1.7.4, using the same logic as for regular non-social user registrations:
At the end of the pipeline I have a validate partial function that does this:
And in settings I have this:
The
INACTIVE_USER_URLis being picked up, but the user is not logged in.Any idea why this wouldn't work as expected?
Thanks!
Russell.