summaryrefslogtreecommitdiff
path: root/lib/users
diff options
context:
space:
mode:
Diffstat (limited to 'lib/users')
-rw-r--r--lib/users/auth/verifyCredentails.ts4
-rw-r--r--lib/users/repository.ts7
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/users/auth/verifyCredentails.ts b/lib/users/auth/verifyCredentails.ts
index 8cb3c434..b3dcd270 100644
--- a/lib/users/auth/verifyCredentails.ts
+++ b/lib/users/auth/verifyCredentails.ts
@@ -6,7 +6,7 @@ import crypto from 'crypto';
// (처리 불필요) 키 암호화를 위한 fs 모듈 사용, 형제 경로 사용하며 public 경로 아니므로 파일이 노출되지 않음.
import fs from 'fs';
import path from 'path';
-import { eq, and, desc, gte, count } from 'drizzle-orm';
+import { eq, and, desc, gte, count ,sql } from 'drizzle-orm';
import db from '@/db/db';
import {
users,
@@ -291,7 +291,7 @@ export async function verifyExternalCredentials(
.from(users)
.where(
and(
- eq(users.email, username),
+ sql`LOWER(${users.email}) = LOWER(${username})`, // 대소문자 구분 없이 비교
eq(users.isActive, true) // 활성 유저만
)
)
diff --git a/lib/users/repository.ts b/lib/users/repository.ts
index 121a1eaa..46ee1e48 100644
--- a/lib/users/repository.ts
+++ b/lib/users/repository.ts
@@ -2,7 +2,7 @@
import db from '@/db/db';
import { users, otps, type User, Role, roles, userRoles } from '@/db/schema/users';
import { Otp } from '@/types/user';
-import { eq,and ,asc} from 'drizzle-orm';
+import { eq,and ,asc,sql} from 'drizzle-orm';
// 모든 사용자 조회
export const getAllUsers = async (): Promise<User[]> => {
@@ -55,12 +55,13 @@ export const getUserByEmail = async (
): Promise<User | null> => {
const { includeInactive = false } = options
- let whereCondition = eq(users.email, email)
+ let whereCondition = sql`LOWER(${users.email}) = LOWER(${email})`
// 기본적으로 활성 사용자만 조회
if (!includeInactive) {
whereCondition = and(
- eq(users.email, email),
+ // eq(users.email, email),
+ sql`LOWER(${users.email}) = LOWER(${email})`,
eq(users.isActive, true)
)!
}