Новые глобабальные правки
This commit is contained in:
parent
b5b31f8a88
commit
36a3d37ad3
8 changed files with 35 additions and 26 deletions
|
|
@ -456,7 +456,11 @@ import { SITE_URL } from '@constants';
|
|||
const response = await fetch('/api/auth/sign-in', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, password }),
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
password,
|
||||
redirect: new URLSearchParams(window.location.search).get('redirect')
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
|
@ -469,8 +473,14 @@ import { SITE_URL } from '@constants';
|
|||
// Сохраняем токен в куку для API
|
||||
document.cookie = `pb_auth=${data.token}; path=/; max-age=${7 * 24 * 60 * 60}; SameSite=Lax`;
|
||||
|
||||
// Перенаправляем в личный кабинет
|
||||
window.location.href = '/cabinet';
|
||||
// Перенаправляем на указанный URL или в личный кабинет
|
||||
const redirectUrl = data.redirect || '/cabinet';
|
||||
|
||||
// Если есть хэш с ID комментариев - добавляем его к URL
|
||||
const hash = new URLSearchParams(window.location.search).get('hash');
|
||||
const finalUrl = hash ? `${redirectUrl}#comments` : redirectUrl;
|
||||
|
||||
window.location.href = finalUrl;
|
||||
} else if (data.error?.includes('подтверждён')) {
|
||||
showError(emailInput, data.error);
|
||||
} else if (data.error?.includes('пароль')) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue