-
Notifications
You must be signed in to change notification settings - Fork 992
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #38108 - As a user I want to invalidate tokens for self(UI)
- Loading branch information
1 parent
bc2dbbf
commit bed624f
Showing
7 changed files
with
111 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
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 { openConfirmModal } from '../../ConfirmModal'; | ||
import { APIActions } from '../../../redux/API'; | ||
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"> | ||
<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: () => | ||
__( | ||
'Successfully Invalidated registration tokens.' | ||
), | ||
errorToast: () => __('Unexpected error occurred.'), | ||
}) | ||
), | ||
}) | ||
) | ||
} | ||
> | ||
{__('Invalidate JWTs')} | ||
</Button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</Fragment> | ||
); | ||
}; | ||
|
||
JwtTokens.propTypes = { | ||
userId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default JwtTokens; |