Тестовый коммит после удаления husky
This commit is contained in:
@@ -3,7 +3,7 @@ const { Pool } = require('pg');
|
||||
// Подключение к БД
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false
|
||||
ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ async function linkIdentity(userId, identityType, identityValue) {
|
||||
'SELECT * FROM user_identities WHERE identity_type = $1 AND identity_value = $2',
|
||||
[identityType, identityValue]
|
||||
);
|
||||
|
||||
|
||||
if (existingResult.rows.length > 0) {
|
||||
// Если идентификатор уже связан с другим пользователем, возвращаем ошибку
|
||||
if (existingResult.rows[0].user_id !== userId) {
|
||||
@@ -30,13 +30,13 @@ async function linkIdentity(userId, identityType, identityValue) {
|
||||
// Если идентификатор уже связан с этим пользователем, ничего не делаем
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Добавляем новую связь
|
||||
await pool.query(
|
||||
'INSERT INTO user_identities (user_id, identity_type, identity_value, created_at) VALUES ($1, $2, $3, NOW())',
|
||||
[userId, identityType, identityValue]
|
||||
);
|
||||
|
||||
|
||||
console.log(`Successfully linked ${identityType}:${identityValue} to user ${userId}`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
@@ -57,11 +57,11 @@ async function getUserIdByIdentity(identityType, identityValue) {
|
||||
'SELECT user_id FROM user_identities WHERE identity_type = $1 AND identity_value = $2',
|
||||
[identityType, identityValue]
|
||||
);
|
||||
|
||||
|
||||
if (result.rows.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return result.rows[0].user_id;
|
||||
} catch (error) {
|
||||
console.error('Error getting user ID by identity:', error);
|
||||
@@ -80,7 +80,7 @@ async function getUserIdentities(userId) {
|
||||
'SELECT identity_type, identity_value FROM user_identities WHERE user_id = $1',
|
||||
[userId]
|
||||
);
|
||||
|
||||
|
||||
return result.rows;
|
||||
} catch (error) {
|
||||
console.error('Error getting user identities:', error);
|
||||
@@ -91,5 +91,5 @@ async function getUserIdentities(userId) {
|
||||
module.exports = {
|
||||
linkIdentity,
|
||||
getUserIdByIdentity,
|
||||
getUserIdentities
|
||||
};
|
||||
getUserIdentities,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user