fix registration on production
This commit is contained in:
@ -29,6 +29,7 @@ import {
|
|||||||
isNotificationsEnabled,
|
isNotificationsEnabled,
|
||||||
getNotifPositionFromSettings,
|
getNotifPositionFromSettings,
|
||||||
} from '../utils/notifications';
|
} from '../utils/notifications';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
const ColorlibConnector = styled(StepConnector)(({ theme }) => ({
|
const ColorlibConnector = styled(StepConnector)(({ theme }) => ({
|
||||||
[`&.${stepConnectorClasses.alternativeLabel}`]: {
|
[`&.${stepConnectorClasses.alternativeLabel}`]: {
|
||||||
@ -168,6 +169,8 @@ export const Registration = () => {
|
|||||||
horizontal: 'center',
|
horizontal: 'center',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const showNotification = (
|
const showNotification = (
|
||||||
message: React.ReactNode,
|
message: React.ReactNode,
|
||||||
severity: 'success' | 'info' | 'warning' | 'error' = 'info',
|
severity: 'success' | 'info' | 'warning' | 'error' = 'info',
|
||||||
@ -197,15 +200,15 @@ export const Registration = () => {
|
|||||||
showNotification('Заполните все поля', 'warning');
|
showNotification('Заполните все поля', 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password !== enterpassword) {
|
if (password !== enterpassword) {
|
||||||
showNotification('Пароли не совпадают', 'warning');
|
showNotification('Пароли не совпадают', 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await registerUser(username, password);
|
const response = await registerUser(username, password);
|
||||||
|
|
||||||
if (response.status === 'success') {
|
if (response.status === 'success') {
|
||||||
setActiveStep(1);
|
setActiveStep(1);
|
||||||
showNotification('Аккаунт создан. Перейдите к верификации.', 'success');
|
showNotification('Аккаунт создан. Перейдите к верификации.', 'success');
|
||||||
@ -290,7 +293,7 @@ export const Registration = () => {
|
|||||||
const handleVerifyCode = async () => {
|
const handleVerifyCode = async () => {
|
||||||
const response = await getVerificationStatus(username);
|
const response = await getVerificationStatus(username);
|
||||||
if (response.is_verified) {
|
if (response.is_verified) {
|
||||||
window.location.href = '/login';
|
navigate('/login', { replace: true });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user