django-lazysignup
django-lazysignup copied to clipboard
Making is_lazy_user return false if connected with django-allauth
I'm trying to integrate django-lazysignup, and django-allauth. I've modified the convert page to linking to a social account. Once this is done I want is_lazy_user to return False as login should happen via allauth now. I've had a look at the template tag code and it checks user.backend, which I'm setting to '' in the allauth login routine. Specifically I modified complete_social_login() in allauth/socialaccount/helpers.py to include the following at Line 107
# New social account
account.user = request.user
account.sync(data)
messages.add_message \
(request, messages.INFO,
_('The social account has been connected to your existing account'))
try:
#TODO check if the values exist first
#account.user.username = generate_unique_username(data.get('username', email or 'user'))
#account.user.username = "testmanualsetting"
account.user.last_name = data.get('last_name', '')[0:User._meta.get_field('last_name').max_length]
account.user.first_name = data.get('first_name', '')[0:User._meta.get_field('first_name').max_length]
account.user.lazyuser_set.all().delete()
account.user.backend = ''
account.user.save()
except:
pass
Also I noted that it falls back on database entries, so I've removed those too. After this is_lazy_user is still returning True. Is this something to do with me updating user.backend on the wrong instance?
I know this isn't really an 'Issue' with lazysignup but wasn't sure where to post for advice.
Thanks in advance,
Nathan
Hi Nathan,
I'm not familiar with allauth. However, you're most likely right - there's probably another instance of the user hanging around, as Django doesn't have an identity mapper. It's difficult to say without seeing the code, though. Try comparing id(account.user) from the code about with id(request.user) from whatever code you're calling is_lazy_user with.
If you can put together some code that demonstrates the problem (perhaps in a github repo?) that I can just check out and run, then I'll try to see if I can see what's going on.
Any news on this?
No, I don't think any work has been done on this integration - unless it's in a repo I don't know about!
No, I've not had any further time to dedicate to this. Its a nice to have feature, but has not been required to date. I'm confident there is a solution that isn't too complex.