🔧 승인 대기 로직 수정 - is_active=False 사용
Some checks failed
SonarQube Analysis / SonarQube Scan (push) Has been cancelled
Some checks failed
SonarQube Analysis / SonarQube Scan (push) Has been cancelled
- access_level='pending' 대신 is_active=False 사용 - access_level='worker'로 설정 (승인 시 변경 가능) - 승인 대기 쿼리: is_active=FALSE로 조회 - 승인 쿼리: user_id 컬럼명 수정 - 거부 쿼리도 user_id 기준으로 수정 필요 로그인 제한: - 로그인 API에서 이미 is_active 체크 중 - 비활성 계정은 로그인 불가 - 관리자 승인 후에만 로그인 가능
This commit is contained in:
@@ -78,12 +78,12 @@ async def signup_request(
|
||||
'password': hashed_password, # 필드명은 'password'
|
||||
'name': signup_data.name,
|
||||
'email': signup_data.email,
|
||||
'access_level': 'pending', # 승인 대기
|
||||
'access_level': 'worker', # 기본 레벨 (승인 시 변경 가능)
|
||||
'department': signup_data.department,
|
||||
'position': signup_data.position,
|
||||
'phone': signup_data.phone,
|
||||
'role': 'user',
|
||||
'is_active': False # 비활성 상태
|
||||
'is_active': False # 비활성 상태로 승인 대기 표시
|
||||
})
|
||||
|
||||
# 가입 사유 저장 (notes 컬럼 활용)
|
||||
@@ -130,13 +130,13 @@ async def get_signup_requests(
|
||||
detail="관리자만 접근 가능합니다"
|
||||
)
|
||||
|
||||
# 승인 대기 중인 사용자 조회
|
||||
# 승인 대기 중인 사용자 조회 (is_active=False인 사용자)
|
||||
query = text("""
|
||||
SELECT
|
||||
id, username, name, email, department, position,
|
||||
user_id as id, username, name, email, department, position,
|
||||
phone, notes, created_at
|
||||
FROM users
|
||||
WHERE access_level = 'pending' AND is_active = FALSE
|
||||
WHERE is_active = FALSE
|
||||
ORDER BY created_at DESC
|
||||
""")
|
||||
|
||||
@@ -203,8 +203,8 @@ async def approve_signup(
|
||||
SET is_active = TRUE,
|
||||
access_level = :access_level,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = :user_id AND access_level = 'pending'
|
||||
RETURNING id, username, name
|
||||
WHERE user_id = :user_id AND is_active = FALSE
|
||||
RETURNING user_id as id, username, name
|
||||
""")
|
||||
|
||||
result = db.execute(update_query, {
|
||||
|
||||
Reference in New Issue
Block a user