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

Verification link in welcome mail #3992

Merged

Conversation

shubhscoder
Copy link
Contributor

Fixes #3850

  1. The welcome email would now contain, link for verification of email
  2. Upon successful verification, the is_verified gets updated

@plotsbot
Copy link
Collaborator

plotsbot commented Nov 16, 2018

1 Message
📖 @shubhscoder Thank you for your pull request! I’m here to help with some tips and recommendations. Please take a look at the list provided and help us review and accept your contribution! And don’t be discouraged if you see errors – we’re here to help.

Generated by 🚫 Danger

@tsparksh
Copy link
Member

if decrypted_user_id != 0
    User.find(decrypted_user_id).update_column(:is_verified, true)
    action_msg = "Successfully verified email"
end

If I'm right, this code will update the is_verified field even when the user has already activated an account. Can you change it?

Copy link
Member

@tsparksh tsparksh left a comment

Choose a reason for hiding this comment

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

Thank you!

@@ -18,6 +18,13 @@

Looking forward to hearing from you soon,

Please click on the link below to verify your email.

<% verifaction_link="https://publiclab.org/verify/#{@user.generate_token}" %>
Copy link
Member

Choose a reason for hiding this comment

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

Here we could replace publiclab.org with <%= ActionMailer::Base.default_url_options[:host] %> so it's not host-specific!

Copy link
Contributor Author

@shubhscoder shubhscoder Nov 22, 2018

Choose a reason for hiding this comment

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

Yeah I fixed that. Thank you so much!

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

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

Hello, would you be able to add a functional test for this ? Thank you!!!

@shubhscoder
Copy link
Contributor Author

shubhscoder commented Nov 30, 2018 via email

@jywarren
Copy link
Member

jywarren commented Nov 30, 2018 via email

@shubhscoder
Copy link
Contributor Author

I tried writing the tests and encountered this error "undefined method []' for true:TrueClass from lib/authlogic_openid/authlogic_openid/acts_as_authentic.rb:74:in save'
" on line " user_obj.update(:is_verified => true)" in users_controller. Tried debugging it but to no avail. @jywarren do you know why this is happening? Thanking you in advance!

@jywarren
Copy link
Member

jywarren commented Dec 17, 2018 via email

@shubhscoder
Copy link
Contributor Author

shubhscoder commented Dec 17, 2018 via email

@jywarren
Copy link
Member

Hmm, @SidharthBansal do you have any ideas on this?

@SidharthBansal SidharthBansal added this to the OAuth milestone Dec 18, 2018
@SidharthBansal
Copy link
Member

Can you @shubhscoder please push in the failing tests so that we can help you?

@shubhscoder shubhscoder force-pushed the verification_link_in_welcome_mail branch from b0c50d2 to f5b97ce Compare December 22, 2018 09:29
@shubhscoder
Copy link
Contributor Author

@SidharthBansal I have pushed the failing tests. Sorry for the delay!

@SidharthBansal SidharthBansal removed this from the OAuth milestone Dec 24, 2018
@shubhscoder
Copy link
Contributor Author

shubhscoder commented Dec 30, 2018

@SidharthBansal @jywarren I realised why the tests are failing. The users_controller_test is using the fixtures to get its object, where as the object gets updated in the users_controller, which updates it in the sql database, that is why the is_verified of the fixtures object never gets updated. I don't think there is a way to write tests for such a scenario. I have tested everything on the localhost I can make a video of the same to make sure that everything is working. Any help/ suggestion is welcome. Thank you so much!

@shubhscoder shubhscoder closed this Jan 8, 2019
@shubhscoder shubhscoder reopened this Jan 8, 2019
Minor changes


Redirection of routes


Added verification link in the welcome email


Update is_verified only if user is not already verified


Tests added


fixed tests
@shubhscoder shubhscoder force-pushed the verification_link_in_welcome_mail branch from d20d40f to b74bbcb Compare January 8, 2019 16:39
@shubhscoder
Copy link
Contributor Author

@SidharthBansal check if this looks good to you, or we need more changes. Thank you so much!

@SidharthBansal
Copy link
Member

@jywarren changes looks good to me. It is important PR so your careful review is must.

@shubhscoder
Copy link
Contributor Author

@jywarren I think this is ready! You can check this? I can make any further changes if required.

@jywarren
Copy link
Member

jywarren commented Feb 6, 2019

This is really nicely implemented, thanks! Just a few questions:

  1. what currently happens when unverified?
  2. relatedly, could we roll this out and then measure a bit whether people are successfully verifying even if we aren't yet requiring it? That'd give us a chance to build confidence in this workflow
  3. what about people who join by OAuth, do we exempt them?

Thanks!

@shubhscoder
Copy link
Contributor Author

@jywarren

  1. Currently if the user is not verified then nothing happens (He is allowed to access everything) but after we merge addition of flash to verify email #4493 the user will start getting a prompt on the dashboard page to verify his email( Again even after addition of flash to verify email #4493 he is not restricted from doing anything.)

  2. Yeah, that sounds a good idea, but in this PR the current users wont know that we have introduced a new email verification process. We would be able to check with only the people who join public labs after we merge this.

  3. For the people joining with Oauth we have not made any provision yet, but yes we could exempt them if required
    Thank you!

@jywarren
Copy link
Member

jywarren commented Feb 7, 2019

This is great! Thank you for the clear response.

  1. current users wont know that we have introduced a new email verification process. We would be able to check with only the people who join public labs after we merge this.

Great, this is fine. Let's make these follow-up steps in an issue and this can be merged!

@jywarren jywarren merged commit e731d60 into publiclab:master Feb 7, 2019
@jywarren
Copy link
Member

jywarren commented Feb 7, 2019

And... THANK YOU!!! 👍 👍 👍

<%= link_to "#{verifaction_link}", verifaction_link%>

In case you are not able to click the link, try copy pasting the link in the browser.

Copy link
Member

Choose a reason for hiding this comment

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

Hi @jywarren make sure too copy this change to the welcome-email-body feature whenever you push this PR to production as the changes made here are just on the fallback email body and the production would send the email using the welcome-email-body feature's content(if it's present).

Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Ah, then this is an issue - we can't execute code in the features system, so this will need to be moved outside the <% end %> on this line: https://github.com/publiclab/plots2/pull/3992/files/b74bbcbd3d85ff70b18bc7eae14bf79105270976#diff-a3214821bc5b12012e6fbb54ad82f05aR29

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jywarren . Sorry but I am not getting what we are supposed to do?

Copy link
Contributor Author

@shubhscoder shubhscoder Feb 10, 2019

Choose a reason for hiding this comment

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

Oh I think I got it. We need to move the verification link and the corresponding instructions regarding the mail outside the if else block right? Because if body is present then the verification link wont appear , so we need to move it outside the block. I will make a new PR for that. Thank you so much for the help!

@jywarren
Copy link
Member

jywarren commented Feb 8, 2019

@shubhscoder do you see our comments above? I think this needs one more change, sorry!

@grvsachdeva
Copy link
Member

grvsachdeva commented Feb 10, 2019 via email

@shubhscoder shubhscoder mentioned this pull request Feb 10, 2019
5 tasks
SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this pull request May 5, 2019
Minor changes


Redirection of routes


Added verification link in the welcome email


Update is_verified only if user is not already verified


Tests added


fixed tests
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.

6 participants