v1.10.88 품질·보안 개선과 미디어 카탈로그 database 전환을 반영한다.
세션·로그인 제한, ZIP/업로드 스트리밍, CSP 최소 강제와 Report-Only, Playwright 격리 검증을 추가하고 미디어 목록을 reconcile 후 database 모드로 고정한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,11 @@ import { createError, readBody } from 'h3'
|
||||
import { getUserByEmail, touchUserActivity } from '../../repositories/member-repository'
|
||||
import { setMemberSession } from '../../utils/member-auth'
|
||||
import { getClientIp } from '../../utils/request-ip'
|
||||
import {
|
||||
assertLoginAttemptAllowed,
|
||||
clearLoginAccountFailures,
|
||||
recordLoginFailure
|
||||
} from '../../utils/login-attempt-limit'
|
||||
|
||||
const loginSchema = z.object({
|
||||
email: z.string().trim().email(),
|
||||
@@ -27,19 +32,34 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const body = parsedBody.data
|
||||
const emailNorm = body.email.trim().toLowerCase()
|
||||
const ip = getClientIp(event)
|
||||
const attempt = {
|
||||
scope: 'member',
|
||||
email: emailNorm,
|
||||
ip
|
||||
}
|
||||
|
||||
assertLoginAttemptAllowed(event, attempt)
|
||||
|
||||
const user = await getUserByEmail(emailNorm)
|
||||
|
||||
if (!user || !(await bcrypt.compare(body.password, user.passwordHash))) {
|
||||
recordLoginFailure(attempt)
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
message: '이메일 또는 비밀번호가 올바르지 않습니다.'
|
||||
})
|
||||
}
|
||||
|
||||
setMemberSession(event, { userId: user.id, email: user.email })
|
||||
clearLoginAccountFailures(attempt)
|
||||
setMemberSession(event, {
|
||||
userId: user.id,
|
||||
email: user.email,
|
||||
sessionVersion: user.sessionVersion
|
||||
})
|
||||
await touchUserActivity({
|
||||
userId: user.id,
|
||||
ip: getClientIp(event)
|
||||
ip
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user