diff --git a/frontend/locales/en.json b/frontend/locales/en.json index e8315677c..d6217b915 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -561,7 +561,8 @@ "message": "Your account has been registered successfully. You can now log in with your username and password." }, "error": { - "registrationDisabled": "The registration is disabled", + "passwordTooWeak": "The password is too weak.", + "registrationDisabled": "The registration is disabled.", "usernameExisting": "There is already an account with this username.", "other": "There was an error while registering your account. Just try it again." } diff --git a/frontend/src/api/auth/local.ts b/frontend/src/api/auth/local.ts index ce2a58abd..c2af57f58 100644 --- a/frontend/src/api/auth/local.ts +++ b/frontend/src/api/auth/local.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -36,6 +36,7 @@ export const doLocalLogin = async (username: string, password: string): Promise< * @param username The username of the new user. * @param displayName The display name of the new user. * @param password The password of the new user. + * @throws {RegisterError.PASSWORD_TOO_WEAK} when the backend deems the password too weak. * @throws {RegisterError.USERNAME_EXISTING} when there is already an existing user with the same username. * @throws {RegisterError.REGISTRATION_DISABLED} when the registration of local users has been disabled on the backend. * @throws {Error} when the api request wasn't successful. @@ -48,7 +49,8 @@ export const doLocalRegister = async (username: string, displayName: string, pas password }) .withStatusCodeErrorMapping({ - 400: RegisterError.REGISTRATION_DISABLED, + 400: RegisterError.PASSWORD_TOO_WEAK, + 403: RegisterError.REGISTRATION_DISABLED, 409: RegisterError.USERNAME_EXISTING }) .sendRequest() diff --git a/frontend/src/api/auth/types.ts b/frontend/src/api/auth/types.ts index b34629a34..b7c549ccc 100644 --- a/frontend/src/api/auth/types.ts +++ b/frontend/src/api/auth/types.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -12,6 +12,7 @@ export enum AuthError { export enum RegisterError { USERNAME_EXISTING = 'usernameExisting', + PASSWORD_TOO_WEAK = 'passwordTooWeak', REGISTRATION_DISABLED = 'registrationDisabled', OTHER = 'other' } diff --git a/frontend/src/components/register-page/register-error/register-error.tsx b/frontend/src/components/register-page/register-error/register-error.tsx index ae5bf3de6..2064b1369 100644 --- a/frontend/src/components/register-page/register-error/register-error.tsx +++ b/frontend/src/components/register-page/register-error/register-error.tsx @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -22,6 +22,8 @@ export const RegisterError: React.FC = ({ error }) => { const errorMessageI18nKey = useMemo(() => { switch (error) { + case RegisterErrorType.PASSWORD_TOO_WEAK: + return 'login.register.error.passwordTooWeak' case RegisterErrorType.REGISTRATION_DISABLED: return 'login.register.error.registrationDisabled' case RegisterErrorType.USERNAME_EXISTING: