feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
normalizeContentPasswordRecoveryCapability,
|
||||
normalizeContentPasswordResetPayload,
|
||||
normalizeContentPasswordResource
|
||||
} from './content-password-recovery-contract.js'
|
||||
import { normalizeGenealogyPathId } from './genealogy-contract.js'
|
||||
import { requestStrict } from './request-client.js'
|
||||
|
||||
const recoveryPath = (genealogyId, resourceType, resourceId) => {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const resource = normalizeContentPasswordResource(resourceType, resourceId)
|
||||
return `/genealogy/app/genealogies/${normalizedGenealogyId}/content-password-recovery/${resource.resourceType}/${resource.resourceId}`
|
||||
}
|
||||
|
||||
export const contentPasswordRecoveryApi = {
|
||||
async getCapability(genealogyId, resourceType, resourceId, requestOptions = {}) {
|
||||
const capability = await requestStrict({
|
||||
url: `${recoveryPath(genealogyId, resourceType, resourceId)}/capability`,
|
||||
method: 'GET'
|
||||
}, { requestController: requestOptions.requestController ?? null })
|
||||
return normalizeContentPasswordRecoveryCapability(capability)
|
||||
},
|
||||
|
||||
async sendCode(genealogyId, resourceType, resourceId, requestOptions = {}) {
|
||||
await requestStrict({
|
||||
url: `${recoveryPath(genealogyId, resourceType, resourceId)}/code`,
|
||||
method: 'POST'
|
||||
}, {
|
||||
requireData: false,
|
||||
requestController: requestOptions.requestController ?? null
|
||||
})
|
||||
return { cooldownSeconds: 60 }
|
||||
},
|
||||
|
||||
async resetPassword(genealogyId, resourceType, resourceId, payload, requestOptions = {}) {
|
||||
await requestStrict({
|
||||
url: `${recoveryPath(genealogyId, resourceType, resourceId)}/reset`,
|
||||
method: 'POST',
|
||||
data: normalizeContentPasswordResetPayload(payload)
|
||||
}, {
|
||||
requireData: false,
|
||||
requestController: requestOptions.requestController ?? null
|
||||
})
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user