debug: добавлено логирование для диагностики сброса пароля
This commit is contained in:
parent
b46a6ecd38
commit
486cb53488
1 changed files with 11 additions and 0 deletions
|
|
@ -4,6 +4,9 @@ const PB_POCKETBASE_URL = import.meta.env.PB_POCKETBASE_URL || 'http://localhost
|
|||
const PB_ADMIN_EMAIL = import.meta.env.PB_ADMIN_EMAIL || 'redibedi2019@gmail.com';
|
||||
const PB_ADMIN_PASSWORD = import.meta.env.PB_ADMIN_PASSWORD || 'Stalin4444';
|
||||
|
||||
console.log('[DEBUG] PB_ADMIN_EMAIL:', PB_ADMIN_EMAIL);
|
||||
console.log('[DEBUG] PB_ADMIN_PASSWORD exists:', !!PB_ADMIN_PASSWORD);
|
||||
|
||||
const PASSWORD_MIN_LENGTH = 8;
|
||||
const PASSWORD_MAX_LENGTH = 12;
|
||||
const PASSWORD_REGEX = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d_!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+$/;
|
||||
|
|
@ -30,6 +33,8 @@ async function getUserIdByResetToken(token: string): Promise<string | null> {
|
|||
try {
|
||||
const adminToken = await getAdminToken();
|
||||
|
||||
console.log('[DEBUG] Searching for token:', token);
|
||||
|
||||
const response = await fetch(`${PB_POCKETBASE_URL}/api/collections/users/records?filter=reset_token="${token}"&limit=1`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${adminToken}`
|
||||
|
|
@ -39,10 +44,14 @@ async function getUserIdByResetToken(token: string): Promise<string | null> {
|
|||
if (!response.ok) return null;
|
||||
|
||||
const data = await response.json();
|
||||
console.log('[DEBUG] Search result:', data);
|
||||
|
||||
if (data.items && data.items.length > 0) {
|
||||
console.log('[DEBUG] User found:', data.items[0].id);
|
||||
return data.items[0].id;
|
||||
}
|
||||
|
||||
console.log('[DEBUG] No user found with this token');
|
||||
return null;
|
||||
} catch (e) {
|
||||
console.error('[CONFIRM_RESET] Error getting user by token:', e);
|
||||
|
|
@ -77,6 +86,8 @@ export const POST: APIRoute = async ({ request }) => {
|
|||
|
||||
const { token, password, passwordConfirm } = body;
|
||||
|
||||
console.log('[DEBUG] Received token from request:', token);
|
||||
|
||||
if (!token) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: 'Токен сброса пароля обязателен' }),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue