macropin / django-registration

Django-registration (redux) provides user registration functionality for Django websites.
http://django-registration-redux.readthedocs.org
Other
974 stars 350 forks source link

activation email not work #298

Closed peterwu2006 closed 6 years ago

peterwu2006 commented 6 years ago

Hi buddies,

I have a problem when I installed a new fresh version 1.8. The activation email to user after registration could NOT be sendoff, meanwhile after login admin view I could send email manually with 'resend activation email' button. anyone could help me? many thanks. When I switch to 'admin_approval' mode, the email to admin right after user registration could NOT be found as well.

peterwu2006 commented 6 years ago

attached my configuration here,

in url.py url(r'^accounts/', include('registration.backends.admin_approval.urls')),

in settings.py (email settings are NOT presented, but I am sure that's correct, because I could sent out email via other apps)

joshblum commented 6 years ago

@peterwu2006 for completeness can you provide the email settings? Did the admin approval interface work on an earlier version of django-registration?

peterwu2006 commented 6 years ago

@joshblum I found the clue, my setting below is not correct. Thanks for your reminder. SEND_ACTIVATION_EMAIL = False

when I change it to True, everything is OK now.

peterwu2006 commented 6 years ago

@joshblum Sorry my bother you again,

I found when I switch back to admin_approval mode,

the email activation email will still send to the user, but no email sending to admin for the approval.

joshblum commented 6 years ago

@peterwu2006 no problem! can you take a look at the function https://github.com/macropin/django-registration/blob/e9b314d4c11c22b89e010934cc31c14a3fb0276f/registration/models.py#L453 and try debugging the code path to check if the email is sent? Is it possible you tried approving a user that already had the is_active flag set to True so no mail was sent?

peterwu2006 commented 6 years ago

@joshblum

I tried to debug, it seems the entire process have no chance to pass through the row 453 you mentioned above.

try: import pdb; pdb.set_trace() profile = SupervisedRegistrationProfile.objects.get(id=profile_id) if profile.activated: if profile.user.is_active: return profile.user

but the process truly went through class SupervisedRegistrationManager, because once I add ' import pdb; pdb.set_trace()' as below, the console could capture it.

`class SupervisedRegistrationManager(RegistrationManager):

import pdb; pdb.set_trace()

def _activate(self, profile, site, get_profile):`
joshblum commented 6 years ago

@peterwu2006 can you debug which part of the code breaks down? Once you click the admin email, it seems that the rough code path is:

https://github.com/macropin/django-registration/blob/e9b314d4c11c22b89e010934cc31c14a3fb0276f/registration/views.py#L157

to

https://github.com/macropin/django-registration/blob/e9b314d4c11c22b89e010934cc31c14a3fb0276f/registration/backends/admin_approval/views.py#L49

to

https://github.com/macropin/django-registration/blob/e9b314d4c11c22b89e010934cc31c14a3fb0276f/registration/backends/admin_approval/views.py#L62

See how far the request makes it through this pass it should show why the approval isn't going through.

peterwu2006 commented 6 years ago

@joshblum

Traced with debug, but it seems all debug points are not be passed through. I found the result is once I register new user , the first stop is

row 12 in django-registration/registration/backends/admin_approval/views.py with 'class RegistrationView(BaseRegistrationView): ' `

joshblum commented 6 years ago

I'm pretty sure that the debugger will stop at that line during the class instantiation, but it won't actually help us debug. Do you have any other info like the request logs that can help the debug process?

peterwu2006 commented 6 years ago

@joshblum Besides setup url.py as below, any other config need to be figure out? url(r'^accounts/', include('registration.backends.admin_approval.urls')),

it seems the register process could NOT go into any function in Supervisedxxxxx class view or profile, many thanks.

ioparaskev commented 6 years ago

@peterwu2006 Have you properly set the ADMINS setting on your settings.py ? Can you add a debugger at the send_admin_approve_email in the following line to see if it passes and with what values? https://github.com/macropin/django-registration/blob/e9b314d4c11c22b89e010934cc31c14a3fb0276f/registration/models.py#L548

peterwu2006 commented 6 years ago

@ioparaskev I'd like to close this case as I find a alternative way. Thanks a lot.