mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
fix: SA unique token bug (#2901)
Fixes a small bug on service account token creation where the tokens the new one was being validated against were not the most up-to-date ones.
This commit is contained in:
parent
b3fcc97f93
commit
90d7737338
@ -7,21 +7,21 @@ import {
|
||||
PersonalAPITokenForm,
|
||||
} from 'component/user/Profile/PersonalAPITokensTab/CreatePersonalAPIToken/PersonalAPITokenForm/PersonalAPITokenForm';
|
||||
import { ICreatePersonalApiTokenPayload } from 'hooks/api/actions/usePersonalAPITokensApi/usePersonalAPITokensApi';
|
||||
import { IServiceAccount } from 'interfaces/service-account';
|
||||
import { IPersonalAPIToken } from 'interfaces/personalAPIToken';
|
||||
|
||||
const DEFAULT_EXPIRATION = ExpirationOption['30DAYS'];
|
||||
|
||||
interface IServiceAccountCreateTokenDialogProps {
|
||||
open: boolean;
|
||||
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
serviceAccount: IServiceAccount;
|
||||
tokens: IPersonalAPIToken[];
|
||||
onCreateClick: (newToken: ICreatePersonalApiTokenPayload) => void;
|
||||
}
|
||||
|
||||
export const ServiceAccountCreateTokenDialog = ({
|
||||
open,
|
||||
setOpen,
|
||||
serviceAccount,
|
||||
tokens,
|
||||
onCreateClick,
|
||||
}: IServiceAccountCreateTokenDialogProps) => {
|
||||
const [patDescription, setPatDescription] = useState('');
|
||||
@ -40,9 +40,7 @@ export const ServiceAccountCreateTokenDialog = ({
|
||||
}, [open]);
|
||||
|
||||
const isDescriptionUnique = (description: string) =>
|
||||
!serviceAccount.tokens?.some(
|
||||
token => token.description === description
|
||||
);
|
||||
!tokens?.some(token => token.description === description);
|
||||
|
||||
const isPATValid =
|
||||
patDescription.length &&
|
||||
|
@ -322,7 +322,7 @@ export const ServiceAccountTokens = ({
|
||||
<ServiceAccountCreateTokenDialog
|
||||
open={createOpen}
|
||||
setOpen={setCreateOpen}
|
||||
serviceAccount={serviceAccount}
|
||||
tokens={tokens}
|
||||
onCreateClick={onCreateClick}
|
||||
/>
|
||||
<ServiceAccountTokenDialog
|
||||
|
Loading…
Reference in New Issue
Block a user