Skip to content
Snippets Groups Projects
Unverified Commit 6938bcd1 authored by Hugo Costa's avatar Hugo Costa Committed by GitHub
Browse files

fix: Manually approved user registration flow (#29420)

parent 3de66415
No related branches found
No related tags found
No related merge requests found
---
"@rocket.chat/web-ui-registration": patch
---
fix: Manually approved user registration flow
The new user gets redirected to the login page with a toast message saying:
> Before you can login, your account must be manually activated by an administrator.
import { useUniqueId } from '@rocket.chat/fuselage-hooks';
import { FieldGroup, TextInput, Field, PasswordInput, ButtonGroup, Button, TextAreaInput } from '@rocket.chat/fuselage';
import { Form, ActionLink } from '@rocket.chat/layout';
import { useSetting } from '@rocket.chat/ui-contexts';
import { useSetting, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { useForm } from 'react-hook-form';
import { Trans, useTranslation } from 'react-i18next';
......@@ -33,6 +33,8 @@ export const RegisterForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRo
const formLabelId = useUniqueId();
const registerUser = useRegisterMethod();
const dispatchToastMessage = useToastMessageDispatch();
const {
register,
handleSubmit,
......@@ -62,6 +64,13 @@ export const RegisterForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRo
if (/Username is already in use/.test(error.error)) {
setError('username', { type: 'username-already-exists', message: t('registration.component.form.userAlreadyExist') });
}
if (/error-too-many-requests/.test(error.error)) {
dispatchToastMessage({ type: 'error', message: error.error });
}
if (/error-user-is-not-activated/.test(error.error)) {
dispatchToastMessage({ type: 'info', message: t('registration.page.registration.waitActivationWarning') });
setLoginRoute('login');
}
},
},
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment