1
0
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:
Nuno Góis 2023-01-16 12:10:08 +00:00 committed by GitHub
parent b3fcc97f93
commit 90d7737338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -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 &&

View File

@ -322,7 +322,7 @@ export const ServiceAccountTokens = ({
<ServiceAccountCreateTokenDialog
open={createOpen}
setOpen={setCreateOpen}
serviceAccount={serviceAccount}
tokens={tokens}
onCreateClick={onCreateClick}
/>
<ServiceAccountTokenDialog