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

1358 add email verification functionalty #1442

Merged
merged 51 commits into from
Aug 24, 2018

Conversation

ivermac
Copy link
Contributor

@ivermac ivermac commented Jul 24, 2018

No description provided.

return False

if view.action == 'send_verification_email':
if request.user.username == request.data.get('username'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the equality returns a boolean, why not return that instead of writing your own returns w/bools?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I'll change it.

except RegistrationProfile.DoesNotExist:
pass
else:
response_message = "Email was NOT verified"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text should use localization

if redirect_url:
return HttpResponseRedirect(redirect_url)

response_message = "Email has been verified."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text should use localization

@onaio onaio deleted a comment Jul 24, 2018
@onaio onaio deleted a comment Jul 24, 2018
@onaio onaio deleted a comment from ivermac Jul 24, 2018
@onaio onaio deleted a comment from ivermac Jul 24, 2018
@onaio onaio deleted a comment Jul 25, 2018
@onaio onaio deleted a comment Jul 25, 2018
@ivermac ivermac changed the title 1358 add email verification functionalty DNM - 1358 add email verification functionalty Jul 25, 2018
@ivermac ivermac changed the title DNM - 1358 add email verification functionalty 1358 add email verification functionalty Jul 25, 2018

@action(detail=False)
def verify_email(self, request, *args, **kwargs):
webhook = settings.EMAIL_VERIFICATION_WEBHOOK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we handle these settings variable with gettattr()? Hence do nothing if the settings are not in place and not break existing installations when they update without the setting in their local_settings.py.

getattr(settings, 'EMAIL_VERIFICATION_WEBHOOK', None)

Tha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your concern and I had considered it while working on this feature. I need to add documentation for the this endpoints and the settings variables that need to be set. So if you checkout the if-block that follows this line, you'll notice that if ENABLE_EMAIL_VERIFICATION is not set to true, the email verification endpoints won't be accessible and a user will get a 403. This means current installations won't be affected. If you set it to true, you have to set all the other email verification settings as well for the feature to work. In my opinion, if the app fails with a 500, the dev team would know that they need to set the settings variables that are required. Returning a None if the variable does not exist won't be helpful because all those variables are required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree you should add API documentation for this endpoint.

However, on the 500 error, I would rather we define default behaviour if those values are not set and provide examples of how that can be defined as you have done on the docker settings file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'll define a default behaviour.

{% blocktrans with expiration_days=expiration_days username=username expiration_days_p=expiration_days|pluralize %}
Hi {{ username }},

To verify your email please click on the link below:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you start a language discussion on this with the product team internally, I think it may need some improvement unless this is exactly the same as the default done by the registration app.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that this might need improvement. I'll start the discussion. The template was mainly used to check that the email functionality works.

@onaio onaio deleted a comment Jul 26, 2018
@onaio onaio deleted a comment Jul 26, 2018
@ivermac ivermac force-pushed the 1358-add-email-verification-functionalty branch from 35590ff to abccef2 Compare July 30, 2018 07:39
@ivermac ivermac changed the title 1358 add email verification functionalty DNM-1358 add email verification functionalty Jul 30, 2018
@onaio onaio deleted a comment Jul 30, 2018
@onaio onaio deleted a comment Jul 30, 2018
@ivermac ivermac changed the title DNM-1358 add email verification functionalty 1358 add email verification functionalty Jul 31, 2018
pass
else:
response_message = _("Email was NOT verified")
if webhook:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's send a 204 if there's a no webhook, so the sender knows we've processed this, so add an else here

@onaio onaio deleted a comment Aug 3, 2018
@onaio onaio deleted a comment Aug 3, 2018
@onaio onaio deleted a comment Aug 3, 2018
@onaio onaio deleted a comment Aug 3, 2018
@onaio onaio deleted a comment Aug 3, 2018
@onaio onaio deleted a comment Aug 3, 2018
@onaio onaio deleted a comment Aug 10, 2018
@onaio onaio deleted a comment Aug 10, 2018
@onaio onaio deleted a comment Aug 10, 2018
@onaio onaio deleted a comment Aug 13, 2018
- Set is_email_verified to True if the email is valid
- Return the username and the email status of the  verified account

Signed-off-by: ivermac <[email protected]>
Test responses and redirect urls query params

Signed-off-by: ivermac <[email protected]>
- Added utility function `_get_email_data` that not only returns email_data
  but also asserts that keys are in emai_data object
- Remove unused utility function `get_kwargs`

Signed-off-by: ivermac <[email protected]>
Functions from the future library can be used in both python 2 and 3

Signed-off-by: ivermac <[email protected]>
The function sets the value of is_email_verified to either True or False

Signed-off-by: ivermac <[email protected]>
Function is used to send verification email

Signed-off-by: ivermac <[email protected]>
Issue will be fixed by master then I'll rebase master with this branch

Signed-off-by: ivermac <[email protected]>
Updated it to commit f711368180d58eef87eda54fadfd5f8355623d52; I messed up when rebasing

Signed-off-by: ivermac <[email protected]>
Both functions don't use the self object

Signed-off-by: ivermac <[email protected]>
- Use mutliple args instead of one dict arg
- Raise error if any of the args is missing

Signed-off-by: ivermac <[email protected]>
- Replace multiple instances of enable_email_verification with getattr(settings, 'ENABLE_EMAIL_VERIFICATION', False)
- Destructure email_data when passing it to send_verification_email.delay

Signed-off-by: ivermac <[email protected]>
- Rename ona_verified_username and ona_verified_username to username and is_email_verified respectively
- Destructure email_data when calling send_verification_email.delay

Signed-off-by: ivermac <[email protected]>
@ivermac ivermac force-pushed the 1358-add-email-verification-functionalty branch from 87f8405 to 662b7fe Compare August 22, 2018 05:14
@onaio onaio deleted a comment Aug 24, 2018
@onaio onaio deleted a comment Aug 24, 2018
@ukanga ukanga merged commit 779ae71 into master Aug 24, 2018
@ukanga ukanga deleted the 1358-add-email-verification-functionalty branch August 24, 2018 09:57
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

Successfully merging this pull request may close these issues.

3 participants