[FEAT] (사용자 로직): 프로필 서비스 구현 완료
v0.1.3 (2025-11-16) - 프로필 조회, 프로필 업데이트, 탈퇴 구현 완료.
This commit is contained in:
@@ -165,4 +165,46 @@ class JWTBlacklistService:
|
||||
def is_blacklisted(cls, jti: str) -> bool:
|
||||
"""토큰이 블랙리스트에 있는지 확인"""
|
||||
key = cls._get_key(jti)
|
||||
return CacheService.exists(key)
|
||||
return CacheService.exists(key)
|
||||
|
||||
|
||||
class AccountLockService:
|
||||
"""계정 잠금 관리 서비스 (Redis 기반)"""
|
||||
|
||||
PREFIX = "account:lock:"
|
||||
TTL = settings.ACCOUNT_LOCKOUT_DURATION_MINUTES * 60 # 분을 초로 변환
|
||||
|
||||
@classmethod
|
||||
def _get_key(cls, user_uuid: str) -> str:
|
||||
"""잠금 키 생성"""
|
||||
return f"{cls.PREFIX}{user_uuid}"
|
||||
|
||||
@classmethod
|
||||
def lock(cls, user_uuid: str, ttl: Optional[int] = None) -> bool:
|
||||
"""계정 잠금 (Redis에 TTL과 함께 저장)"""
|
||||
key = cls._get_key(user_uuid)
|
||||
ttl = ttl or cls.TTL
|
||||
|
||||
if not CacheService._is_redis_available():
|
||||
logger.warning("레디스가 연결되어 있지 않습니다. 계정 잠금이 불가능합니다.")
|
||||
return False
|
||||
|
||||
success = CacheService.set(key, "1", ttl)
|
||||
if success:
|
||||
logger.info(f"계정 잠금 완료: {user_uuid} (TTL: {ttl}s)")
|
||||
return success
|
||||
|
||||
@classmethod
|
||||
def is_locked(cls, user_uuid: str) -> bool:
|
||||
"""계정이 잠겨있는지 확인"""
|
||||
key = cls._get_key(user_uuid)
|
||||
return CacheService.exists(key)
|
||||
|
||||
@classmethod
|
||||
def unlock(cls, user_uuid: str) -> bool:
|
||||
"""계정 잠금 해제"""
|
||||
key = cls._get_key(user_uuid)
|
||||
success = CacheService.delete(key)
|
||||
if success:
|
||||
logger.info(f"계정 잠금 해제 완료: {user_uuid}")
|
||||
return success
|
||||
Reference in New Issue
Block a user