-
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="tab-pane" id="jwt_tokens"> | ||
<%= react_component('JwtTokens', { | ||
userId: @user.id, | ||
}) %> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { Fragment } from 'react'; | ||
import { Button } from '@patternfly/react-core'; | ||
import { KeyIcon } from '@patternfly/react-icons'; | ||
import { useDispatch } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import { APIActions } from '../../../redux/API'; | ||
import { openConfirmModal } from '../../ConfirmModal'; | ||
import { translate as __ } from '../../../common/I18n'; | ||
|
||
const JwtTokens = ({ userId }) => { | ||
const dispatch = useDispatch(); | ||
return ( | ||
<Fragment> | ||
<table className="table table-bordered table-striped table-hover table-fixed"> | ||
stejskalleos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<tbody> | ||
<tr> | ||
<td className="blank-slate-pf"> | ||
<div className="blank-slate-pf-icon"> | ||
<KeyIcon type="fa" name="key" color="#9c9c9c" /> | ||
</div> | ||
<h1>{__('JWT Tokens')}</h1> | ||
<p> | ||
{__( | ||
'By invalidating your JSON Web Tokens (JWTs), you will no longer be able to register hosts by using your existing JWTs.' | ||
)} | ||
</p> | ||
<Button | ||
ouiaId="invalidate-jwt-token-button" | ||
variant="primary" | ||
isSmall | ||
onClick={() => | ||
dispatch( | ||
openConfirmModal({ | ||
isWarning: true, | ||
title: __('Invalidate tokens for self?'), | ||
confirmButtonText: __('Confirm'), | ||
onConfirm: () => | ||
dispatch( | ||
APIActions.patch({ | ||
url: `/users/${userId}/invalidate_jwt`, | ||
key: `INVALIDATE-JWT`, | ||
successToast: () => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if the call is not successful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will not happen, Like we discussed in the first story PR, there will be no case when invalidation won't work. I can add a safety failed toast, what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if user was logged out meanwhile? The Rails will respond with 501 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are sending There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's not true. You do in>your< controller, but what if there is a problem on the network, DNS, or somewhere else? How do you handle that error? |
||
__('Successfully Invalidated JWTs'), | ||
}) | ||
), | ||
}) | ||
) | ||
} | ||
> | ||
{__('Invalidate JWTs')} | ||
</Button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</Fragment> | ||
); | ||
}; | ||
|
||
JwtTokens.propTypes = { | ||
userId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default JwtTokens; |
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.
What if the
userID
is not set?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.
If the user is logged in, we always have the @user object set and we are sending it from here so I don't think that would happen