0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00

feat(shared,phrases-ui): not allow hyphens in username (#1319)

This commit is contained in:
IceHe.xyz 2022-07-01 03:18:44 +08:00 committed by GitHub
parent 441660716c
commit 5e819665c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 6 deletions

View file

@ -53,8 +53,8 @@ export class LogtoContext {
public async init() {
const account = {
username: generatePassword(),
password: generateUsername(),
username: generateUsername(),
password: generatePassword(),
};
const codeVerifier = generateCodeVerifier();
const codeChallenge = await generateCodeChallenge(codeVerifier);

View file

@ -6,5 +6,5 @@ export const extractCookie = (response: Response) => {
return headers['set-cookie']?.join('; ') ?? '';
};
export const generateUsername = () => `usr-${crypto.randomUUID()}`;
export const generatePassword = () => `pwd-${crypto.randomUUID()}`;
export const generateUsername = () => `usr_${crypto.randomUUID().replaceAll('-', '_')}`;
export const generatePassword = () => `pwd_${crypto.randomUUID()}`;

View file

@ -58,7 +58,7 @@ const translation = {
password_required: 'Password is required',
username_exists: 'Username already exists',
username_should_not_start_with_number: 'Username should not start with a number',
username_valid_charset: 'Username should only contain letters, numbers, or underscore.',
username_valid_charset: 'Username should only contain letters, numbers, or underscores.',
invalid_email: 'The email is invalid',
invalid_phone: 'The phone number is invalid',
password_min_length: 'Password requires a minimum of {{min}} characters',

View file

@ -1,6 +1,6 @@
export const emailRegEx = /^\S+@\S+\.\S+$/;
export const phoneRegEx = /^\d+$/;
export const usernameRegEx = /^[A-Z_a-z-][\w-]*$/;
export const usernameRegEx = /^[A-Z_a-z]\w*$/;
export const passwordRegEx = /^.{6,}$/;
export const redirectUriRegEx = /^https?:\/\//;
export const hexColorRegEx = /^#[\da-f]{3}([\da-f]{3})?$/i;