해당 서비스 도커화 성공, 룰 추가, 로그인 오류 수정, 소문자 룰 어느정도 해결
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
const dbPool = require('../dbPool');
|
||||
const { getDb } = require('../dbPool');
|
||||
|
||||
// 사용자 조회
|
||||
const findByUsername = async (username) => {
|
||||
let connection;
|
||||
try {
|
||||
connection = await dbPool.getConnection();
|
||||
const [rows] = await connection.query(
|
||||
const db = await getDb();
|
||||
const [rows] = await db.query(
|
||||
'SELECT * FROM users WHERE username = ?', [username]
|
||||
);
|
||||
return rows[0];
|
||||
} catch (err) {
|
||||
console.error('DB 오류 - 사용자 조회 실패:', err);
|
||||
throw err;
|
||||
} finally {
|
||||
if (connection) connection.release();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,18 +19,15 @@ const findByUsername = async (username) => {
|
||||
* @param {number} userId - 사용자 ID
|
||||
*/
|
||||
const incrementFailedLoginAttempts = async (userId) => {
|
||||
let connection;
|
||||
try {
|
||||
connection = await dbPool.getConnection();
|
||||
await connection.execute(
|
||||
const db = await getDb();
|
||||
await db.execute(
|
||||
'UPDATE users SET failed_login_attempts = failed_login_attempts + 1 WHERE user_id = ?',
|
||||
[userId]
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('DB 오류 - 로그인 실패 횟수 증가 실패:', err);
|
||||
throw err;
|
||||
} finally {
|
||||
if (connection) connection.release();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,18 +36,15 @@ const incrementFailedLoginAttempts = async (userId) => {
|
||||
* @param {number} userId - 사용자 ID
|
||||
*/
|
||||
const lockUserAccount = async (userId) => {
|
||||
let connection;
|
||||
try {
|
||||
connection = await dbPool.getConnection();
|
||||
await connection.execute(
|
||||
const db = await getDb();
|
||||
await db.execute(
|
||||
'UPDATE users SET locked_until = DATE_ADD(NOW(), INTERVAL 15 MINUTE) WHERE user_id = ?',
|
||||
[userId]
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('DB 오류 - 계정 잠금 실패:', err);
|
||||
throw err;
|
||||
} finally {
|
||||
if (connection) connection.release();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -62,18 +53,15 @@ const lockUserAccount = async (userId) => {
|
||||
* @param {number} userId - 사용자 ID
|
||||
*/
|
||||
const resetLoginAttempts = async (userId) => {
|
||||
let connection;
|
||||
try {
|
||||
connection = await dbPool.getConnection();
|
||||
await connection.execute(
|
||||
const db = await getDb();
|
||||
await db.execute(
|
||||
'UPDATE users SET last_login_at = NOW(), failed_login_attempts = 0, locked_until = NULL WHERE user_id = ?',
|
||||
[userId]
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('DB 오류 - 로그인 상태 초기화 실패:', err);
|
||||
throw err;
|
||||
} finally {
|
||||
if (connection) connection.release();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user