You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using social registration with userena to login facebook users and have an issue.
I have the following code for the connect signal:
def social_connect_callback(sender, user, profile, client, **kwargs):
"""
Create a profile for this user after connecting
'''
userenaSignup = UserenaSignup.objects.get_or_create(user=user)
# Create profile for user
try:
print 'getting an account'
new_profile = UserProfile.objects.get(user=user)
except:
print 'creating new user'
new_profile = UserProfile.objects.create(user=user)
if not user.first_name:
user.first_name = fb_profile['first_name']
if not user.last_name:
user.last_name = fb_profile['last_name']
if not user.email:
user.email = fb_profile['email']
user.save()
# Give permissions to view and change profile
for perm in ASSIGNED_PERMISSIONS['profile']:
assign(perm[0], user, new_profile)
# Give permissions to view and change itself
for perm in ASSIGNED_PERMISSIONS['user']:
assign(perm[0], user, user)
This is code doesn't deal with existing emails so we end up with two records with the same email which causes Userena to break if the user attempts to login the traditional way(username/email, password).
How can I prevent this from happening. I tried to check and see if the fb_profile['email'] existed already but can't delete the current record tied to the user object passed to the and authenticate the user with the existing record.
The text was updated successfully, but these errors were encountered:
Hello,
I'm using social registration with userena to login facebook users and have an issue.
I have the following code for the connect signal:
def social_connect_callback(sender, user, profile, client, **kwargs):
"""
Create a profile for this user after connecting
'''
signals.connect.connect(social_connect_callback, sender=FacebookProfile, dispatch_uid = 'facebook_connect')
This is code doesn't deal with existing emails so we end up with two records with the same email which causes Userena to break if the user attempts to login the traditional way(username/email, password).
How can I prevent this from happening. I tried to check and see if the fb_profile['email'] existed already but can't delete the current record tied to the user object passed to the and authenticate the user with the existing record.
The text was updated successfully, but these errors were encountered: