app端取消用户注册和token验证,改为按设备ID识别用户

- 删除注册、登录、找回密码、游客登录接口及密码、token 相关代码
- 鉴权中间件不再校验 token,按 X-User-Agent 中的 devID 识别用户,首次访问自动创建,Redis 缓存 10 分钟
- 渠道码改从请求头 channel 读取;修改资料不再支持改密码
- 同步更新 swagger 文档

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-23 16:22:10 +08:00
co-authored by Claude Opus 5.5
parent d6599ae004
commit 4efdbfeffc
10 changed files with 123 additions and 1462 deletions
+3 -280
View File
@@ -58,7 +58,7 @@ const docTemplate = `{
},
"/api/app/auth/getInfo": {
"get": {
"description": "通过 token 获取最新用户信息,包含金币余额、VIP状态等",
"description": "按请求头 X-User-Agent 中的 devID 识别用户,返回最新用户信息,包含金币余额、VIP状态等",
"produces": [
"application/json"
],
@@ -82,89 +82,9 @@ const docTemplate = `{
}
}
},
"/api/app/auth/guest": {
"post": {
"description": "按设备ID创建或找回游客账号;请求头可带 Authorization 复用已有游客会话。需传 X-User-Agent",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"用户认证"
],
"summary": "游客登录",
"parameters": [
{
"description": "游客登录参数",
"name": "param",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/authser.GuestLoginReq"
}
}
],
"responses": {
"200": {
"description": "成功",
"schema": {
"$ref": "#/definitions/authser.LoginResp"
}
},
"400": {
"description": "失败",
"schema": {
"type": "string"
}
}
}
}
},
"/api/app/auth/login": {
"post": {
"description": "账号或邮箱均可作为登录凭证",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"用户认证"
],
"summary": "登录",
"parameters": [
{
"description": "登录参数",
"name": "param",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/authapi.loginReq"
}
}
],
"responses": {
"200": {
"description": "登录成功,返回 token 及用户基本信息",
"schema": {
"$ref": "#/definitions/authser.LoginResp"
}
},
"400": {
"description": "失败",
"schema": {
"type": "string"
}
}
}
}
},
"/api/app/auth/profile": {
"post": {
"description": "用户信息通过 token 获取,无需传账号;nickName、avatar、introduction、oldPassword+newPassword 均为可选,至少提供一项。修改密码时旧密码和新密码必须同时提供。",
"description": "按请求头 X-User-Agent 中的 devID 识别用户;nickName、avatar、introduction、privacyMode 均为可选,至少提供一项。",
"consumes": [
"application/json"
],
@@ -174,7 +94,7 @@ const docTemplate = `{
"tags": [
"用户认证"
],
"summary": "修改用户资料(头像 / 简介 / 密码,可任意组合)",
"summary": "修改用户资料(昵称 / 头像 / 简介 / 隐私模式,可任意组合)",
"parameters": [
{
"description": "修改资料参数",
@@ -202,86 +122,6 @@ const docTemplate = `{
}
}
},
"/api/app/auth/register": {
"post": {
"description": "传入账号、邮箱、明文密码。请求头带游客 Authorization 时升级该游客为普通用户,否则新建用户",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"用户认证"
],
"summary": "注册",
"parameters": [
{
"description": "注册参数",
"name": "param",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/authapi.registerReq"
}
}
],
"responses": {
"200": {
"description": "注册成功,返回 token 及用户基本信息",
"schema": {
"$ref": "#/definitions/authser.LoginResp"
}
},
"400": {
"description": "失败",
"schema": {
"type": "string"
}
}
}
}
},
"/api/app/auth/resetPassword": {
"post": {
"description": "通过账号和邮箱双重校验后重置密码,两者必须同时匹配同一用户",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"用户认证"
],
"summary": "找回密码",
"parameters": [
{
"description": "找回密码参数",
"name": "param",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/authapi.resetPasswordReq"
}
}
],
"responses": {
"200": {
"description": "成功",
"schema": {
"type": "string"
}
},
"400": {
"description": "失败",
"schema": {
"type": "string"
}
}
}
}
},
"/api/app/coin/buy": {
"post": {
"security": [
@@ -2295,87 +2135,6 @@ const docTemplate = `{
}
},
"definitions": {
"authapi.loginReq": {
"type": "object",
"required": [
"account",
"password"
],
"properties": {
"account": {
"description": "账号或邮箱",
"type": "string"
},
"channel": {
"description": "渠道码(可选,用户无商区码时写入)",
"type": "string"
},
"devID": {
"description": "设备唯一标示(可选)",
"type": "string"
},
"password": {
"description": "明文密码",
"type": "string"
}
}
},
"authapi.registerReq": {
"type": "object",
"required": [
"accountNo",
"email",
"password"
],
"properties": {
"accountNo": {
"description": "账号",
"type": "string"
},
"agentInviteCode": {
"description": "邀请人的邀请码(可选)",
"type": "string"
},
"channel": {
"description": "渠道码(可选,用户无商区码时写入)",
"type": "string"
},
"devID": {
"description": "设备唯一标示(可选)",
"type": "string"
},
"email": {
"description": "邮箱",
"type": "string"
},
"password": {
"description": "明文密码",
"type": "string"
}
}
},
"authapi.resetPasswordReq": {
"type": "object",
"required": [
"accountNo",
"email",
"newPassword"
],
"properties": {
"accountNo": {
"description": "账号",
"type": "string"
},
"email": {
"description": "邮箱",
"type": "string"
},
"newPassword": {
"description": "新密码",
"type": "string"
}
}
},
"authapi.updateProfileReq": {
"type": "object",
"properties": {
@@ -2387,45 +2146,16 @@ const docTemplate = `{
"description": "简介(可选)",
"type": "string"
},
"newPassword": {
"description": "新密码明文(修改密码时必填)",
"type": "string"
},
"nickName": {
"description": "新昵称(可选)",
"type": "string"
},
"oldPassword": {
"description": "旧密码明文(修改密码时必填)",
"type": "string"
},
"privacyMode": {
"description": "隐私模式:true-开启,false-关闭(可选)",
"type": "boolean"
}
}
},
"authser.GuestLoginReq": {
"type": "object",
"properties": {
"channel": {
"description": "渠道码(可选,用户无商区码时写入 DistrictCode)",
"type": "string"
},
"devID": {
"description": "设备唯一标示(必填)",
"type": "string"
},
"deviceId": {
"description": "备用设备ID(可选,写入 DevV2)",
"type": "string"
},
"mac": {
"description": "设备 Mac(可选)",
"type": "string"
}
}
},
"authser.LoginResp": {
"type": "object",
"properties": {
@@ -2451,10 +2181,6 @@ const docTemplate = `{
"description": "邀请码",
"type": "string"
},
"isNewUser": {
"description": "本次是否新建游客",
"type": "boolean"
},
"isRegister": {
"description": "是否已注册",
"type": "boolean"
@@ -2493,9 +2219,6 @@ const docTemplate = `{
"status": {
"$ref": "#/definitions/pubdef.UserStatus"
},
"token": {
"type": "string"
},
"type": {
"description": "身份类型:0游客 1普通用户",
"allOf": [