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 becoming user password hint#168385051 #712

Conversation

BasilMawejje
Copy link

PT Story: Admin: becoming a user UX : needs hint about password

PT URL: https://www.pivotaltracker.com/story/show/168385051

Changes proposed in this pull request:

  1. When an admin becomes a user and clicks 'Edit your profile' in the header dropdown menu, a pop up should come to the screen to remind the admin to use the admin password as the current password. This should happen when the admin sets focus to the current password field.

  2. If the admin uses the tab key to navigate to the current password field, the pop up should still be activated to remind the admin which password to use.

Screenshots (Optional):

Screenshot 2019-09-13 at 15 17 34


Ready for review:

@patmbolger @thesuss @weedySeaDragon

Add admin_only_become_user route to path_helpers
Add feature file for admin becoming user password hint
Add steps for admin becoming user password hint
All tests green
.modal-header
%h5.modal-title= t(".modalTitle")
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
%span{"aria-hidden" => "true"} ×

Choose a reason for hiding this comment

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

Hash attribute should start with one space after the opening brace
Hash attribute should end with one space before the closing brace

@weedySeaDragon
Copy link
Collaborator

@patmbolger - While I was writing cucumber tests for @BasilMawejje, it seemed to me that we have no way to tell if the current user was actually the admin that became this user.

The devise_masquerade gem does all of this: allows you to 'become' ("masquerade as") a user and keeps track if the current user was an admin that 'became' this user

It has a simple method that we can use to see if the current user has been 'masqueraded':
user_masquerade? # current user has been masqueraded (our "admin has 'become' a user")

Instead of writing (and maintaining) our own functionality to do keep track of if an admin has 'become' a user, I think that we should use the devise_masquerade gem to accomplish this. It's a well known gem that has been used for years.

Don't know if we should create a new PT story and PR or what.

But we should all discuss this -- here and/or during the next team meeting.

find('#currentPassword').evaluate_script("$('#currentPassword').focus()")
end

Then("I should see the text {capture_string}") do |capture_string|

Choose a reason for hiding this comment

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

Lint/UnusedBlockArgument: Unused block argument - capture_string. You can omit the argument if you don't care about it.

visit edit_user_registration_path(@user)
end

Then("I focus on {capture_string}{optional_string}") do |capture_string, optional_string|

Choose a reason for hiding this comment

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

Lint/UnusedBlockArgument: Unused block argument - capture_string. You can omit all the arguments if you don't care about them.
Lint/UnusedBlockArgument: Unused block argument - optional_string. You can omit all the arguments if you don't care about them.

visit admin_only_user_profile_edit_path(@user)
end

Then("I should see {capture_string}{optional_string}") do |capture_string, optional_string|

Choose a reason for hiding this comment

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

Lint/UnusedBlockArgument: Unused block argument - capture_string. You can omit all the arguments if you don't care about them.
Lint/UnusedBlockArgument: Unused block argument - optional_string. You can omit all the arguments if you don't care about them.

visit admin_only_become_user_path(@user)
end

Then("I click {capture_string}") do |capture_string|

Choose a reason for hiding this comment

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

Lint/UnusedBlockArgument: Unused block argument - capture_string. You can omit the argument if you don't care about it.

visit admin_only_user_profile_edit_path(@user)
end

Then("I should navigate to {capture_string}") do |capture_string|

Choose a reason for hiding this comment

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

Lint/UnusedBlockArgument: Unused block argument - capture_string. You can omit the argument if you don't care about it.

@@ -0,0 +1,23 @@
Given("I am on the {capture_string}{optional_string}{optional_string}{capture_string}") do |capture_string, optional_string, optional_string2, capture_string2|

Choose a reason for hiding this comment

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

Lint/UnusedBlockArgument: Unused block argument - capture_string. You can omit all the arguments if you don't care about them.
Lint/UnusedBlockArgument: Unused block argument - optional_string. You can omit all the arguments if you don't care about them.
Lint/UnusedBlockArgument: Unused block argument - optional_string2. You can omit all the arguments if you don't care about them.
Lint/UnusedBlockArgument: Unused block argument - capture_string2. You can omit all the arguments if you don't care about them.

@BasilMawejje BasilMawejje changed the title Admin becoming user password hint#168385051 WIP: Admin becoming user password hint#168385051 Sep 17, 2019
@BasilMawejje BasilMawejje changed the title WIP: Admin becoming user password hint#168385051 [WIP] Admin becoming user password hint#168385051 Sep 17, 2019
visit admin_only_user_profile_edit_path(@user)
end

Then(/^I should see "([^"]*)" page$/) do |arg|

Choose a reason for hiding this comment

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

Lint/UnusedBlockArgument: Unused block argument - arg. You can omit the argument if you don't care about it.

@BasilMawejje BasilMawejje force-pushed the admin-becoming-user-password-hint#168385051 branch from 347b529 to 65b12c2 Compare September 18, 2019 08:13
Change admin become user path
Modify spec background to make both users admin in order to work around Pundit error
Add login_as to step file to simulate admin become action

Then("I should navigate to {capture_string}") do |capture_string|
login_as(id = 1)
visit user_path(id = 1)

Choose a reason for hiding this comment

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

Lint/UselessAssignment: Useless assignment to variable - id.

end

Then("I should navigate to {capture_string}") do |capture_string|
login_as(id = 1)

Choose a reason for hiding this comment

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

Lint/UselessAssignment: Useless assignment to variable - id.

@@ -0,0 +1,24 @@
Given("I am on the {capture_string}{optional_string}{optional_string}{capture_string}") do |capture_string, optional_string, optional_string2, capture_string2|
visit admin_only_user_profile_edit_path(id = 1)

Choose a reason for hiding this comment

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

Lint/UselessAssignment: Useless assignment to variable - id.

@BasilMawejje BasilMawejje force-pushed the admin-becoming-user-password-hint#168385051 branch from 85795d5 to b879c8b Compare September 18, 2019 13:09
@BasilMawejje BasilMawejje changed the title [WIP] Admin becoming user password hint#168385051 Admin becoming user password hint#168385051 Sep 18, 2019
@BasilMawejje
Copy link
Author

@weedySeaDragon In the spec background I made both users admins in order to work around the Pundit::NotDefinedError that comes when an admin becomes a non-admin user in the tests. All tests are green. You can review and give me feedback on the implementation.

@BasilMawejje BasilMawejje force-pushed the admin-becoming-user-password-hint#168385051 branch from 45720c9 to c6c5fc6 Compare September 18, 2019 15:25
@weedySeaDragon
Copy link
Collaborator

The system is already doing what it should

Once the admin "becomes" a user, the system expects that the password entered is the user's password.

Hence we discovered we don't need this PR and are closing it.

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