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

admin forced password reset #1834

Merged
merged 11 commits into from
Dec 12, 2017
Merged

admin forced password reset #1834

merged 11 commits into from
Dec 12, 2017

Conversation

Kevin-Kawai
Copy link
Contributor

@Kevin-Kawai Kevin-Kawai commented Dec 8, 2017

Make sure these boxes are checked before your pull request is ready to be reviewed and merged. Thanks!

This is the branch for the issue #232. It allows an admin to start the password reset procedure for a user through their profile page.

  • all tests pass -- rake test:all
  • code is in uniquely-named feature branch, and has been rebased on top of latest master (especially if you've been asked to make additional changes)
  • pull request is descriptively named with #number reference back to original issue

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/wiki/contributing-to-public-lab-software

We have a loose schedule of reviewing and pulling in changes every Tuesday and Friday, and publishing changes on Fridays. Please alert developers on plots-dev@googlegroups.com when your request is ready or if you need assistance.

Thanks!

@Kevin-Kawai Kevin-Kawai mentioned this pull request Dec 8, 2017
post 'register' => 'users#create'
get 'reset' => 'users#reset'
post 'reset' => 'users#reset'
post 'reset/key/:key' => 'users#reset'
get 'reset/key/:key' => 'users#reset'
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 had to change this verb and the above to get in order to get them to work on my local machine. Since they aren't really the parts I had to work on I assume they are correct? And I will revert them back after I have finished.

Copy link
Member

Choose a reason for hiding this comment

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

I think you fixed a latent bug related to the Rails 4 upgrade-- i've spent much of the day chasing a few of these which we missed when doing the routes.rb refactoring. Thank you!

PasswordResetMailer.reset_notify(user, key) unless user.nil? # respond the same to both successes and failures; security
end
flash[:notice] = I18n.t('users_controller.password_reset_email')
redirect_to "/login"
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 think the page should not redirect to the log in page since it's the admin that's starting the password reset

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, can you detect that it's not a typical user and redirect to... the profile page?

config/routes.rb Outdated
@@ -222,6 +222,7 @@
put 'moderate/spam/:id' => 'admin#mark_spam'
put 'moderate/publish/:id' => 'admin#publish'
put 'admin/promote/moderator/:id' => 'admin#promote_moderator'
get 'resetuserpassword/:id' => 'admin#reset_user_password'
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 think this name might not be that great and another path name would be good.

Copy link
Member

Choose a reason for hiding this comment

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

maybe... /user/reset/password ?

@Kevin-Kawai
Copy link
Contributor Author

@jywarren I have created a PR for #232 this is still a work in progress but if you have a chance to take a look and let me know if I'm on the right track that would be great! Thanks!

@PublicLabBot
Copy link

PublicLabBot commented Dec 8, 2017

1 Warning
⚠️ It looks like you merged from master in this pull request. Please rebase to get rid of the merge commits – you may want to rewind the master branch and rebase instead of merging in from master, which can cause problems when accepting new code!
4 Messages
📖 @Kevin-Kawai 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.
📖 Your pull request is on the master branch. Please make a separate feature branch) with a descriptive name like new-blog-design while making PRs in the future.
📖 This pull request doesn’t link to a issue number. Please refer to the issue it fixes (if any) in the body of your PR, in the format: Fixes #123.
📖 It looks like you haven’t marked all the checkboxes. Help us review and accept your suggested changes by going through the steps one by one. If it is still a ‘Work in progresss’, please include ‘[WIP]’ in the title.

Generated by 🚫 Danger

@jywarren
Copy link
Member

jywarren commented Dec 8, 2017

Very cool and apologies for the routes.rb conflicts -- as i mentioned i've been fixing lots of things in that file. Please try to preserve your changes and rebase them into the latest version. I'm happy to help with this of course! Many thanks!

@jywarren
Copy link
Member

jywarren commented Dec 9, 2017

This is looking good -- actually we don't want moderators to be able to force reset -- sorry if that was wrong in the request. Is this otherwise good to go? Awesome!

@Kevin-Kawai
Copy link
Contributor Author

oh sorry that last commit might be misleading. I meant that an Admin can reset a moderator's password if they need to. Or do we not want that to be a possibility?

I think for the most part it is finished. I'm just thinking about changing the flash message that pops up when the Admin resets the password because right now it's the same message as if a user reset it themselves (something like "You should receive an email.....") and maybe "@user's email has been reset. They should receive instructions...."

@Kevin-Kawai
Copy link
Contributor Author

@jywarren I just changed the message so I think the whole PR is good to go! Let me know if there is anything you need me to change

@Kevin-Kawai Kevin-Kawai changed the title [WIP] admin forced password reset admin forced password reset Dec 10, 2017
@@ -43,6 +43,22 @@ def demote_basic
redirect_to '/profile/' + @user.username + '?_=' + Time.now.to_i.to_s
end

def reset_user_password
if current_user && (current_user.role == 'moderator' || current_user.role == 'admin')
Copy link
Member

Choose a reason for hiding this comment

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

Hi, doesn't this mean that moderators would be able to reset passwords? If we could just change this to admins only, that'd be great. Thanks!!!

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 apologize, you are correct. This would allow moderator's to reset a user's password. I will fix this after work and push the changes.

@Kevin-Kawai
Copy link
Contributor Author

@jywarren Sorry about that last bit of confusion. I fixed the controller so the moderator doesn't have the ability to reset passwords. Everything else should be good to go! Let me know if there's anything else.

@jywarren
Copy link
Member

Super, thanks so much!!!

🎉

@jywarren jywarren merged commit a9ae224 into publiclab:master Dec 12, 2017
SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this pull request May 5, 2019
* added admin req pass change action and button on view

* renamed admin force reset route and changed redirect page after reset

* Made it so admin cannot repeatedly press reset button

* added test and changed route name to follow convention

* made it so a moderator acc can be force reset as well

* changed alert message when admin resets password

* fixed merge conflict mistake

* removed moderator ability to reset from controller
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