feat(api): password change endpoint and source device id on uploads
P3 Task 3 契约增补批次(单一事实来源 openapi.yaml + cn 实现 + e2e):
- POST /v1/auth/password-change(operationId changePassword,需求 4.1 的
P1 契约缺口补齐):Bearer + {oldPassword 1-128, newPassword 8-128} → 204;
旧密码错误 401 AUTH_INVALID_CREDENTIALS;成功后事务内更新 argon2 哈希、
撤销该用户除当前会话外的全部其他会话(当前会话保留,本人不下线)、写
审计 auth.password_change。
- sourceDeviceId(A19 设备来源语义):UploadInitRequest 可选 8-64 位设备
标识;upload_sessions 落列(VARCHAR(64) utf8mb4_0900_bin,可空,存量
行 NULL 兼容);GET /uploads 条目回显;幂等重放不比对(first-writer,
首次落库值不随重放漂移)。
- e2e:auth 增 4 例(未认证 401 / 新密码过短 400 / 旧密码错误 401 且会话
无副作用 / 成功后他端会话撤销当前保留 + 新旧密码登录裁决 + 审计);
uploads 增 1 例(携带落库回显、换设备重放保留首值、缺省 null、长度
越界 400)。api e2e 179 → 184;contracts gen/redocly/单测、worker、
sync 门全绿。
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -152,6 +152,41 @@ paths:
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalError'
|
||||
|
||||
/auth/password-change:
|
||||
post:
|
||||
operationId: changePassword
|
||||
tags: [auth]
|
||||
summary: 修改密码
|
||||
description: |
|
||||
已认证用户修改自身密码:校验旧密码,成功后更新密码哈希并撤销该用户
|
||||
除当前会话外的全部其他会话(当前会话保持有效,无需重新登录)。
|
||||
P3 Task 3 契约增补(需求 4.1「支持修改密码」,P1 契约缺口补齐)。
|
||||
security:
|
||||
- bearerAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PasswordChangeRequest'
|
||||
responses:
|
||||
'204':
|
||||
description: 修改成功,无响应体;当前会话保留,其他会话已撤销。
|
||||
'400':
|
||||
description: 参数校验失败(VALIDATION_FAILED,经全局校验管道)。
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'401':
|
||||
description: 旧密码错误(AUTH_INVALID_CREDENTIALS)。
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalError'
|
||||
|
||||
# ─────────────────────────── albums ───────────────────────────
|
||||
|
||||
/albums:
|
||||
@@ -1674,6 +1709,21 @@ components:
|
||||
format: date-time
|
||||
readOnly: true
|
||||
description: 续期后的过期时间。
|
||||
PasswordChangeRequest:
|
||||
type: object
|
||||
description: 修改密码请求(P3 Task 3 契约增补)。
|
||||
required: [oldPassword, newPassword]
|
||||
properties:
|
||||
oldPassword:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
description: 当前密码。
|
||||
newPassword:
|
||||
type: string
|
||||
minLength: 8
|
||||
maxLength: 128
|
||||
description: 新密码(至少 8 位)。
|
||||
|
||||
# ── 相册 ──
|
||||
|
||||
@@ -2138,6 +2188,13 @@ components:
|
||||
type: string
|
||||
enum: [image/jpeg, image/png, image/heic]
|
||||
description: MIME 类型白名单;image/heic 为暂定项,解码能力待 G2 真机验证后确认。
|
||||
sourceDeviceId:
|
||||
type: string
|
||||
minLength: 8
|
||||
maxLength: 64
|
||||
description: |
|
||||
客户端首次生成并持久化的设备标识;服务端历史返回用于区分上传来源
|
||||
(A19)。可选;同一 clientTaskId 幂等重放时保留首次落库的值。
|
||||
|
||||
UploadCredential:
|
||||
type: object
|
||||
@@ -2257,6 +2314,12 @@ components:
|
||||
format: date-time
|
||||
readOnly: true
|
||||
description: 会话创建时间。
|
||||
sourceDeviceId:
|
||||
type: [string, 'null']
|
||||
readOnly: true
|
||||
description: |
|
||||
发起该上传的设备标识(客户端首次生成并持久化;init 时未携带为 null)。
|
||||
P3 Task 3 契约增补(A19 设备来源语义)。
|
||||
photo:
|
||||
$ref: '#/components/schemas/UploadSessionPhoto'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user