task(1ff499d8-9640-4cda-a068-b52bac9f6731): Fix login response contract deviation blocking real device login
- Change AuthApi login and getUserInfo return types to ApiEnvelope<JsonElement>
- Add tokenFromData to handle both string and {"Token":"..."} object responses
- Add userInfoFromData to handle both flat UserInfo and {"UserInfo":"<escaped JSON>"} responses
- Inject Json into SessionRepository for unified deserialization
- Update signIn flow to extract token and user info through unified helpers
- Add contract tolerance documentation explaining V4.5 spec vs test environment behavior
This commit is contained in:
@@ -17,14 +17,19 @@ import retrofit2.http.Query
|
||||
*
|
||||
* 三要素请求头(SecretKey/SystemCode/Token)由 AuthInterceptor 统一注入;
|
||||
* 登录/验证码接口未登录时天然不携带 Token(接口文档 1.2.3)。
|
||||
*
|
||||
* 契约宽容(V4.5 文档 vs 测试环境实测,任务 ca3394be):
|
||||
* - 2.2.1/2.2.3 登录 data 实测为 {"Token":"…"} 对象(文档称 Token 字符串);
|
||||
* - 2.4 用户信息 data 实测为 {"UserInfo":"<二次 JSON 编码字符串>"}(文档称平铺对象)。
|
||||
* 三者均以 [JsonElement] 宽容承载,由 SessionRepository 归一提取后兼容两种口径。
|
||||
*/
|
||||
interface AuthApi {
|
||||
|
||||
/** 2.2.1 账号密码登录:成功 data 为 Token 字符串。 */
|
||||
/** 2.2.1 账号密码登录:data 形态见类注释契约宽容说明。 */
|
||||
@POST(PATH_LOGIN_BY_ACCOUNT)
|
||||
suspend fun loginByAccount(
|
||||
@Body request: PasswordLoginRequest,
|
||||
): ApiEnvelope<String>
|
||||
): ApiEnvelope<JsonElement>
|
||||
|
||||
/**
|
||||
* 2.2.2 发送短信验证码:[mobilePhone] 须已按约定归一
|
||||
@@ -36,11 +41,11 @@ interface AuthApi {
|
||||
@Query(QUERY_MOBILE_PHONE, encoded = true) mobilePhone: String,
|
||||
): ApiEnvelope<JsonElement>
|
||||
|
||||
/** 2.2.3 手机验证码登录:成功 data 为 Token 字符串。 */
|
||||
/** 2.2.3 手机验证码登录:data 形态同 2.2.1,见类注释契约宽容说明。 */
|
||||
@POST(PATH_LOGIN_BY_MOBILE)
|
||||
suspend fun loginByMobile(
|
||||
@Body request: MobileLoginRequest,
|
||||
): ApiEnvelope<String>
|
||||
): ApiEnvelope<JsonElement>
|
||||
|
||||
/** 2.3.1 修改登录密码:登录态下操作,成功 data 为 null。 */
|
||||
@POST(PATH_MODIFY_PASSWORD)
|
||||
@@ -48,9 +53,9 @@ interface AuthApi {
|
||||
@Body request: ChangePasswordRequest,
|
||||
): ApiEnvelope<Unit>
|
||||
|
||||
/** 2.4 获取当前用户信息:需登录态。 */
|
||||
/** 2.4 获取当前用户信息:需登录态,data 形态见类注释契约宽容说明。 */
|
||||
@GET(PATH_GET_USER_INFO)
|
||||
suspend fun getUserInfo(): ApiEnvelope<UserInfo>
|
||||
suspend fun getUserInfo(): ApiEnvelope<JsonElement>
|
||||
|
||||
companion object {
|
||||
// ---- 接口管理规范 V4.5 · 章节 2.1 所有 API 目录 ----
|
||||
|
||||
Reference in New Issue
Block a user