feat: implement P0 security and reliability improvements
- bcrypt password hashing with auto-migration from SHA-256 - BLE command retry (3 attempts, 500ms delay, skip on disconnect) - BLE auto-reconnect with service re-discovery on disconnect - Treatment page disconnect/reconnect event handling - Token refresh endpoint with 3-day grace period - Client-side token auto-refresh when <24h remaining - Single treatment record detail API with ownership check
这个提交包含在:
@@ -55,6 +55,14 @@ function register(router) {
|
||||
await writeLog({ user_id: user.user_id, action: 'treatment_sync', detail: '同步护理记录: ' + sessionId, ip: ctx.ip })
|
||||
return ok({ record_id: sessionId })
|
||||
})
|
||||
|
||||
router.get('/api/v1/treatment/:record_id', async ctx => {
|
||||
const user = await requireUser(ctx)
|
||||
if (!user) return fail(1001, 'invalid_token')
|
||||
const record = await one('SELECT * FROM treatment_records WHERE session_id = :session_id AND user_id = :user_id', { session_id: ctx.params.record_id, user_id: user.user_id })
|
||||
if (!record) return fail(1005, 'record_not_found')
|
||||
return ok(record)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = register
|
||||
|
||||
在新工单中引用
屏蔽一个用户