@blod-nm/user-kit 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/auth.js +4 -2
- package/src/schemas.js +9 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blod-nm/user-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "CloudBase user-center kit: auth (wechat code / unionid / password / sms / email / signup) + crm_user_detail archive on @blod-nm/base-cb.",
|
package/src/auth.js
CHANGED
|
@@ -178,8 +178,10 @@ export function createAuthAbilities(cfg, kit) {
|
|
|
178
178
|
} }],
|
|
179
179
|
|
|
180
180
|
['auth.signup', { describe: '注册(手机/邮箱/provider_token 三形态):POST /auth/v1/signup,响应原样+补 uid+建档', run: async (args = {}) => {
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
// 三种形态:手机号+验证码 / 邮箱+验证码 / provider_token(第三方授权注册)
|
|
182
|
+
const codePath = !!(args?.phone_number || args?.email)
|
|
183
|
+
if (codePath && !args?.verification_token) throw err(400, 'verification_token 必填')
|
|
184
|
+
if (!codePath && !args?.provider_token) throw err(400, 'phone_number/email/provider_token 必填其一')
|
|
183
185
|
const payload = await gw('POST', '/auth/v1/signup', { body: args })
|
|
184
186
|
const uid = uidOfPayload(payload)
|
|
185
187
|
if (!uid) throw err(500, '用户注册失败')
|
package/src/schemas.js
CHANGED
|
@@ -75,14 +75,18 @@ export const SCHEMAS = {
|
|
|
75
75
|
'auth.signup': {
|
|
76
76
|
title: '注册',
|
|
77
77
|
inputSchema: obj({
|
|
78
|
-
phone_number: str('手机号(与 email
|
|
79
|
-
email: str('邮箱(与 phone_number
|
|
80
|
-
|
|
78
|
+
phone_number: str('手机号(与 email / provider_token 三选一)'),
|
|
79
|
+
email: str('邮箱(与 phone_number / provider_token 三选一)'),
|
|
80
|
+
provider_token: str('第三方 provider_token(三选一;与验证码方式互斥)'),
|
|
81
|
+
verification_token: str('验证码令牌(手机/邮箱注册时必填;provider_token 方式不需要)'),
|
|
81
82
|
username: str('用户名(可选)'),
|
|
82
83
|
password: str('密码(可选)'),
|
|
83
84
|
}, {
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
anyOf: [
|
|
86
|
+
{ required: ['verification_token', 'phone_number'] },
|
|
87
|
+
{ required: ['verification_token', 'email'] },
|
|
88
|
+
{ required: ['provider_token'] },
|
|
89
|
+
],
|
|
86
90
|
}),
|
|
87
91
|
outputSchema: obj({ uid: str('唯一用户 id(必返)'), access_token: str('访问令牌(必返)') }, { required: ['uid', 'access_token'] }),
|
|
88
92
|
annotations: { openWorldHint: true },
|