Skip to content

Commit

Permalink
Wizard: Unique default key name
Browse files Browse the repository at this point in the history
Fixes #2353

This adds a random suffix to the default activation key name, making it less predictable.
  • Loading branch information
regexowl authored and ezr-ondrej committed Aug 16, 2024
1 parent 4fa0ad8 commit 0ecf7c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
selectRegistrationType,
} from '../../../../store/wizardSlice';
import { useGetEnvironment } from '../../../../Utilities/useGetEnvironment';
import { generateRandomId } from '../../utilities/generateRandomId';

export const PopoverActivation = () => {
const [orgId, setOrgId] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -106,7 +107,7 @@ const ActivationKeysList = () => {
const activationKey = useAppSelector(selectActivationKey);
const registrationType = useAppSelector(selectRegistrationType);

const defaultActivationKeyName = 'activation-key-default';
const defaultActivationKeyName = `activation-key-default-${generateRandomId()}`;

const { isProd } = useGetEnvironment();
const [isOpen, setIsOpen] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const generateRandomId = () => {
let id = '';
const characterSet = 'abcdefghijklmnopqrstuvwxyz0123456789';
while (id.length < 6) {
id += characterSet.charAt(Math.floor(Math.random() * characterSet.length));
}
return id;
};

0 comments on commit 0ecf7c9

Please sign in to comment.