mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
Merge branch 'main' of https://github.com/IRBorisov/ConceptPortal
This commit is contained in:
commit
b5da4091d8
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -57,4 +57,5 @@ bower_components
|
||||||
|
|
||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
venv/
|
venv/
|
||||||
|
/GitExtensions.settings
|
||||||
|
|
|
@ -77,7 +77,7 @@ export const UserProfileState = ({ children }: UserProfileStateProps) => {
|
||||||
onError: error => { setError(error); },
|
onError: error => { setError(error); },
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
setUser(undefined);
|
setUser(undefined);
|
||||||
auth.logout();
|
auth.reload();
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}});
|
}});
|
||||||
}, [setUser, auth]
|
}, [setUser, auth]
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { useLayoutEffect } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { useAuth } from '../context/AuthContext';
|
import { useAuth } from '../context/AuthContext';
|
||||||
import { TIMEOUT_UI_REFRESH } from '../utils/constants';
|
|
||||||
|
|
||||||
function HomePage() {
|
function HomePage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
@ -10,13 +9,9 @@ function HomePage() {
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
setTimeout(() => {
|
navigate('/library?filter=common');
|
||||||
navigate('/library?filter=common');
|
|
||||||
}, TIMEOUT_UI_REFRESH);
|
|
||||||
} else if(!user.is_staff) {
|
} else if(!user.is_staff) {
|
||||||
setTimeout(() => {
|
navigate('/library?filter=personal');
|
||||||
navigate('/library?filter=personal');
|
|
||||||
}, TIMEOUT_UI_REFRESH);
|
|
||||||
}
|
}
|
||||||
}, [navigate, user])
|
}, [navigate, user])
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,13 @@ export function ChangePassword() {
|
||||||
const [old_password, setOldPassword] = useState('');
|
const [old_password, setOldPassword] = useState('');
|
||||||
const [new_password, setNewPassword] = useState('');
|
const [new_password, setNewPassword] = useState('');
|
||||||
const [new_password_repeat, setNewPasswordRepeat] = useState('');
|
const [new_password_repeat, setNewPasswordRepeat] = useState('');
|
||||||
const [password_equal, setPasswordEqual] = useState(true);
|
const [new_pass_color, setNewPassColor] = useState('');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
|
function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (new_password !== new_password_repeat) {
|
if (new_password !== new_password_repeat) {
|
||||||
setPasswordEqual(false);
|
setNewPassColor('bg-red-500');
|
||||||
toast.error('Пароли не совпадают');
|
toast.error('Пароли не совпадают');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -41,21 +41,21 @@ export function ChangePassword() {
|
||||||
onChange={event => setOldPassword(event.target.value)}
|
onChange={event => setOldPassword(event.target.value)}
|
||||||
/>
|
/>
|
||||||
<TextInput id='new_password'
|
<TextInput id='new_password'
|
||||||
colorClass={`${password_equal ? "" : "text-red-500"}`}
|
colorClass={new_pass_color}
|
||||||
label="Введите новый пароль:"
|
label="Введите новый пароль:"
|
||||||
value={new_password}
|
value={new_password}
|
||||||
onChange={event => {
|
onChange={event => {
|
||||||
setNewPassword(event.target.value);
|
setNewPassword(event.target.value);
|
||||||
setPasswordEqual(true);
|
setNewPassColor('');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<TextInput id='new_password'
|
<TextInput id='new_password_repeat'
|
||||||
colorClass={`${password_equal ? "" : "text-red-500"}`}
|
colorClass={new_pass_color}
|
||||||
label="Повторите новый пароль:"
|
label="Повторите новый пароль:"
|
||||||
value={new_password_repeat}
|
value={new_password_repeat}
|
||||||
onChange={event => {
|
onChange={event => {
|
||||||
setNewPasswordRepeat(event.target.value);
|
setNewPasswordRepeat(event.target.value);
|
||||||
setPasswordEqual(true);
|
setNewPassColor('');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className='relative flex justify-center my-4 border'>
|
<div className='relative flex justify-center my-4 border'>
|
||||||
|
@ -69,4 +69,4 @@ export function ChangePassword() {
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -70,4 +70,4 @@ export function UserProfile() {
|
||||||
<ChangePassword />
|
<ChangePassword />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user