-
Notifications
You must be signed in to change notification settings - Fork 993
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
Fixes #38108 - As a user I want to invalidate tokens for self(UI) #10405
Conversation
f3234ce
to
95f093f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Microcopy review
<h1>{__('JWT Tokens')}</h1> | ||
<p> | ||
{__( | ||
'By invalidating tokens,you will no longer be able to register hosts by using their JWTs.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'By invalidating tokens,you will no longer be able to register hosts by using their JWTs.' | |
'By invalidating your JSON Web Tokens (JWTs), you will no longer be able to register hosts by using your existing JWTs.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
app/controllers/users_controller.rb
Outdated
process_success( | ||
:success_msg => _('Successfully invalidated JWTs for %s.') % @user.login | ||
) | ||
unless editing_self? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? Why not to have same response as before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@girijaasoni I think we should use respond_to
here. It would be more consistent.
webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js
Show resolved
Hide resolved
test "User should be able to invalidate jwt for self" do | ||
User.current = users(:one) | ||
user = User.current | ||
FactoryBot.build(:jwt_secret, token: 'test_jwt_secret', user: user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FactoryBot.build(:jwt_secret, token: 'test_jwt_secret', user: user) | |
FactoryBot.create(:jwt_secret, token: 'test_jwt_secret', user: user) |
With build
the object is not saved in the database, making the assertion pass even if the action was not performing correctly
d19a69c
to
c0c8fdb
Compare
app/controllers/users_controller.rb
Outdated
process_success( | ||
:success_msg => _('Successfully invalidated JWTs for %s.') % @user.login | ||
) | ||
unless editing_self? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@girijaasoni I think we should use respond_to
here. It would be more consistent.
app/controllers/users_controller.rb
Outdated
) | ||
unless editing_self? | ||
process_success( | ||
:success_msg => _('Successfully invalidated JWTs for %s.') % @user.login |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:success_msg => _('Successfully invalidated JWTs for %s.') % @user.login | |
:success_msg => _('Successfully invalidated registration tokens for %s.') % @user.login |
app/views/users/_form.html.erb
Outdated
@@ -18,6 +18,9 @@ | |||
<% if @editing_self || (@user.persisted? && authorized_for(hash_for_api_user_personal_access_tokens_path(user_id: @user))) %> | |||
<li><a href='#personal_access_tokens' data-toggle='tab'><%= _('Personal Access Tokens') %></a></li> | |||
<% end %> | |||
<% if @editing_self %> | |||
<li><a href='#jwt_tokens' data-toggle='tab'><%= _('JWT Tokens') %></a></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<li><a href='#jwt_tokens' data-toggle='tab'><%= _('JWT Tokens') %></a></li> | |
<li><a href='#jwt_tokens' data-toggle='tab'><%= _('Registration Tokens') %></a></li> |
FactoryBot.create(:jwt_secret, token: 'test_jwt_secret', user: user) | ||
patch :invalidate_jwt, params: { :id => user.id }, session: set_session_user(User.current) | ||
user.reload | ||
assert_response :success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add assertion for the user object:
assert_nil user.jwt_token
@stejskalleos Could you please approve this PR so that I can merge it? |
Thanks everyone! |
No description provided.