Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleEmailConfirmationUserMixin Model conflecting with django-role-permissions #65

Open
DanishAbsar opened this issue Aug 17, 2019 · 5 comments

Comments

@DanishAbsar
Copy link

Django 2.2.1
python 3.7.3

pip
django-role-permissions 2.2.1

image

@Nieto2018
Copy link

Nieto2018 commented Dec 3, 2019

Hello @DanishAbsar

I tried in a new Django project and it works, but considering some things:

  • Python 3.7
  • Django 2.2.8

In the step 2 of Installation, use from django.contrib.auth.models import User instead of from django.contrib.auth.models import AbstractUser to avoid your error.

Taking the examples, the first example doesn't work because user = User.objects.create_user(email, email=email) doesn't create any entry into the table simple_email_confirmation_emailaddress, but the example of add another email works well and add a entry so you can use a mixed of both. I think that the first example isn't complete.

@DanishAbsar
Copy link
Author

Thanks @Nieto2018 It works like a charm, but now I'm getting the following error

image

@DanishAbsar
Copy link
Author

In my case, I had another mixin from django-role-permissions

@Nieto2018
Copy link

Nieto2018 commented Dec 13, 2019

Hello @DanishAbsar .I don't know how django-role-permissions affects, but you can try the following code, it should work:

email = '[email protected]'
user = User.objects.create_user(email, email=email)

new_email = '[email protected]'
confirmation_key = user.add_unconfirmed_email(new_email)  # <---- This line should avoid your error
new_email in user.unconfirmed_emails # True

send_mail(new_email, 'Use %s to confirm your new email' % confirmation_key)
# User gets email, passes the confirmation_key back to your server

user.confirm_email(confirmation_key)
new_email in user.confirmed_emails # True

user.set_primary_email(new_email)
user.email # [email protected]

@DanishAbsar
Copy link
Author

Hi, @Nieto2018 sorry for the late response

in my case, I suppose to verify the first email which used by the user during registration.
I'm getting an entry when database, when I create a user with an email, by my user object doen't, contain the confirmaion key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants