auth validation
This commit is contained in:
@@ -27,7 +27,6 @@ const Login = () => {
|
||||
// После успешного логина
|
||||
useEffect(() => {
|
||||
dispatch(setMenuActivePage('account'));
|
||||
submitClicked;
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -47,6 +46,21 @@ const Login = () => {
|
||||
dispatch(loginUser({ username, password }));
|
||||
};
|
||||
|
||||
const getErrorLoginMessage = (): string => {
|
||||
if (!submitClicked) return '';
|
||||
if (username == '') return 'Поле не может быть пустым';
|
||||
if (password == '') return '';
|
||||
if (status === 'failed')
|
||||
return 'Неверное имя пользователя и/или пароль';
|
||||
return '';
|
||||
};
|
||||
|
||||
const getErrorPasswordMessage = (): string => {
|
||||
if (!submitClicked) return '';
|
||||
if (password == '') return 'Поле не может быть пустым';
|
||||
return '';
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-svh w-svw fixed pointer-events-none top-0 left-0 flex items-center justify-center">
|
||||
<div className="grid gap-[80px] grid-cols-[400px,384px] box-border relative ">
|
||||
@@ -73,6 +87,7 @@ const Login = () => {
|
||||
setUsername(v);
|
||||
}}
|
||||
placeholder="login"
|
||||
error={getErrorLoginMessage()}
|
||||
/>
|
||||
<Input
|
||||
name="password"
|
||||
@@ -84,6 +99,7 @@ const Login = () => {
|
||||
setPassword(v);
|
||||
}}
|
||||
placeholder="abCD1234"
|
||||
error={getErrorPasswordMessage()}
|
||||
/>
|
||||
|
||||
<div className="flex justify-end mt-[10px]">
|
||||
|
||||
Reference in New Issue
Block a user