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

clear user name and password on failed login attempt. #2514

Merged
merged 1 commit into from
Oct 26, 2017

Conversation

ohadlevy
Copy link
Member

@ohadlevy ohadlevy commented Oct 25, 2017

I've cleared both user and password, but maybe clearing
just the password is sufficent.

also, this is my first attempt in writing jasmin specs
any comments are welcomed

https://bugzilla.redhat.com/show_bug.cgi?id=1089786

https://www.pivotaltracker.com/n/projects/1613907/stories/152252967

@ohadlevy
Copy link
Member Author

recorded

@@ -722,6 +722,8 @@ function miqAjaxAuth(url) {
})
.then(null, function() {
add_flash(__('Incorrect username or password'), 'error', { id: 'auth_failed' });
$('#user_name').val('');
Copy link
Member Author

Choose a reason for hiding this comment

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

I've noticed the service UI does not clear the username, in the sake of consistency it probably makes sense to do the same or change in both. any opinions? /cc @serenamarie125

@ohadlevy
Copy link
Member Author

test failures seems unrelated?

@chessbyte
Copy link
Member

See related PR in Service UI

@serenamarie125
Copy link

@ohadlevy I can check if there are any conventions on the PatternFly side, but I would guess just clearing the password is enough.

Can you change the button label to "Log In" as part of this PR ?

@ohadlevy ohadlevy force-pushed the reset-user-pass branch 2 times, most recently from b930de4 to f2e3c91 Compare October 25, 2017 18:52
@ohadlevy
Copy link
Member Author

ohadlevy commented Oct 25, 2017

@serenamarie125 updated to only reset password field, changed all login buttons text (and hover) to "Log in"

@serenamarie125
Copy link

@ohadlevy I did check with PatternFly, and although there is currently no "guidance" on what to do about clearing, the consensus is to add documentation around clearing BOTH the username and password upon failed login attempt.

My initial suggestion of only clearing password was around the user experience, meaning if i type in my password incorrectly, do I really have to retype both user name and password ?! But Catherine brought up the fact that she has had discussions with security folks around this, and that the suggestion was to clear both.

Sorry bout that! Thanks for updating the "Log In" as well for button label & tooltip!

@ohadlevy
Copy link
Member Author

@serenamarie125 re-added user field. this is now also consistent with other projects (such as foreman) :)
I'll send a PR to the service-ui shortly

ohadlevy added a commit to ohadlevy/manageiq-ui-service that referenced this pull request Oct 26, 2017
based on discussion on a similar PR on the ops UI (ManageIQ/manageiq-ui-classic#2514 (comment))
I'm suggesting we align across the two.
@serenamarie125
Copy link

I see the updated video with the new behavior, but "Login" doesn't seem to be updated?

@ohadlevy
Copy link
Member Author

@serenamarie125 I didnt update the video, but here is an image
image

@h-kataria
Copy link
Contributor

@ohadlevy this looks good. Verified in UI.

@ohadlevy
Copy link
Member Author

@h-kataria any idea why tests are failing? doesn't seem related - is there any better way to test this kind of change? thanks.

@h-kataria
Copy link
Contributor

@ohadlevy spec test failures seem related to changes in this PR, maybe there is a syntax error in the html string. i will try to look into it.

it('removes password field form log in form', function () {
deferred = $q.defer();
// simulate authentication api call
spyOn(API 'get').andReturn(deferred.promise);
Copy link
Contributor

@h-kataria h-kataria Oct 26, 2017

Choose a reason for hiding this comment

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

@ohadlevy comma missing here
spyOn(API, 'get').andReturn(deferred.promise);
that should fix the test failures

@h-kataria
Copy link
Contributor

This is odd, same tests pass for me locally.

@ohadlevy ohadlevy force-pushed the reset-user-pass branch 3 times, most recently from 80ccdc8 to fb6e25f Compare October 26, 2017 15:12
@dclarizio dclarizio added the rbac label Oct 26, 2017
@dclarizio
Copy link

FWIW, I've seen all 3 scenarios on web based logins: clear both, clear password only, clear none. Since we only clear password in the SUI PR linked above, we should match that for now. Unless we want to change SUI to clear both.

I tend towards only clearing the password, to make it easier for the user, since the user can actually see the userid to know if it's correct.

@ohadlevy
Copy link
Member Author

@dclarizio SUI was updated at ManageIQ/manageiq-ui-service#1162

@miq-bot
Copy link
Member

miq-bot commented Oct 26, 2017

Checked commit ohadlevy@5c0c24d with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 1 offense detected

app/views/dashboard/login.html.haml

  • ⚠️ - Line 28 - Missing curly braces around a hash parameter.

@ohadlevy
Copy link
Member Author

@h-kataria fixed the test failure issue - this is mostly due to the fact that our javascript test infrastructure does not support ES6 js / babel. going forward I would suggest to check alternatives to the way we currently do JS testing. hopefully its ready to merge now - thanks!

@dclarizio dclarizio removed the bug label Oct 26, 2017
@h-kataria h-kataria added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 26, 2017
@h-kataria h-kataria merged commit 7fe3ae7 into ManageIQ:master Oct 26, 2017
@ohadlevy ohadlevy deleted the reset-user-pass branch October 26, 2017 18:26
@serenamarie125
Copy link

"Log In" should have a capital "I" @ohadlevy can you do a separate PR to update?

@ohadlevy
Copy link
Member Author

@serenamarie125 fixed at #2539

deferred = $q.defer();

// simulate failed authentication api call
spyOn(API, 'get').and.callFake(function() {return deferred.reject();});
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the late response.. this spec doesn't do anything... (thanks @mzazrivec for noticing :))

Fixed in #3355, but just so you know :)

  • can't use inject(API) because this is not angular code - login is using vanillaJsAPI, not the angular service
  • can't mock API.get because it is not actually used, vanillaJsAPI.login is called and does the get internally
  • any time we use a promise.then/catch, the code is run asynchronously - and asynchronous expects are ignored in synchronous tests - missing a done param for the it function, jasmine uses the arity of the function to determine whether it's synchronous (arity 0) or asynchronous (arity 1 and you need to call the provided callback when done), so this was a synchronous spec with 0 expects
  • having the mock return a fake promise would make sense if we didn't have to wait, but we can't wait on a then.then.then of a promise without getting the new promise - so miqAjaxAuth needs to return the right promise so that we can wait on it
  • missing spy on miqClearLoginFields
  • badly escaped quotes-within-quotes-within-apostrophes (but we can't really use the onclick anyway)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants