Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello_uni-id-pages
提交
e2445e17
H
hello_uni-id-pages
项目概览
DCloud
/
hello_uni-id-pages
通知
1054
Star
31
Fork
43
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
2
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello_uni-id-pages
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e2445e17
编写于
2月 08, 2023
作者:
C
chenruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(uni-id-co): 优化外部用户联登数据结构
(cherry picked from commit
9bf6dc01
)
上级
d9820861
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
92 addition
and
19 deletion
+92
-19
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/account.js
...es/uniCloud/cloudfunctions/uni-id-co/lib/utils/account.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js
...loud/cloudfunctions/uni-id-co/module/admin/update-user.js
+2
-3
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/external/index.js
...niCloud/cloudfunctions/uni-id-co/module/external/index.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/external/login.js
...niCloud/cloudfunctions/uni-id-co/module/external/login.js
+45
-6
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/external/register.js
...loud/cloudfunctions/uni-id-co/module/external/register.js
+32
-7
uni_modules/uni-id-pages/uniCloud/database/uni-id-users.schema.json
...s/uni-id-pages/uniCloud/database/uni-id-users.schema.json
+9
-1
未找到文件。
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/account.js
浏览文件 @
e2445e17
const
{
db
,
dbCmd
,
userCollection
}
=
require
(
'
../../common/constants
'
)
...
...
@@ -85,6 +84,8 @@ function getUserQueryCondition (userRecord = {}) {
username
:
username
.
toLowerCase
()
})
}
}
else
if
(
key
===
'
identities
'
)
{
queryItem
.
identities
=
dbCmd
.
elemMatch
(
value
)
}
condition
.
push
(
queryItem
)
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js
浏览文件 @
e2445e17
...
...
@@ -83,10 +83,10 @@ module.exports = async function (params = {}) {
username
,
dcloud_appid
:
authorizedApp
,
nickname
,
role
:
role
,
role
,
mobile
,
email
,
tags
:
tags
,
tags
,
status
}
...
...
@@ -132,7 +132,6 @@ module.exports = async function (params = {}) {
await
userCollection
.
doc
(
uid
).
update
(
realData
)
return
{
errCode
:
0
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/external/index.js
浏览文件 @
e2445e17
module
.
exports
=
{
externalRegister
:
require
(
'
./register
'
),
externalLogin
:
require
(
'
./login
'
)
externalLogin
:
require
(
'
./login
'
),
updateUserInfoByExternal
:
require
(
'
./update-user-info
'
)
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/external/login.js
浏览文件 @
e2445e17
const
{
preLogin
,
postLogin
}
=
require
(
'
../../lib/utils/login
'
)
const
{
EXTERNAL_DIRECT_CONNECT_PROVIDER
}
=
require
(
'
../../common/constants
'
)
const
{
ERROR
}
=
require
(
'
../../common/error
'
)
/**
* 外部用户登录
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#external-login
* @param {object} params
* @param {string} params.uid uni-id体系用户id
* @param {string} params.externalUid 业务系统的用户id
* @returns {object}
*/
module
.
exports
=
async
function
(
params
=
{})
{
const
schema
=
{
unieid
:
'
username
'
uid
:
{
required
:
false
,
type
:
'
string
'
},
externalUid
:
{
required
:
false
,
type
:
'
string
'
}
}
this
.
middleware
.
validate
(
params
,
schema
)
const
{
unieid
uid
,
externalUid
}
=
params
const
user
=
await
preLogin
.
call
(
this
,
{
user
:
{
username
:
unieid
if
(
!
uid
&&
!
externalUid
)
{
throw
{
errCode
:
ERROR
.
PARAM_REQUIRED
,
errMsgValue
:
{
param
:
'
uid or externalUid
'
}
}
}
let
query
if
(
uid
)
{
query
=
{
_id
:
uid
}
}
else
{
query
=
{
identities
:
{
provider
:
EXTERNAL_DIRECT_CONNECT_PROVIDER
,
uid
:
externalUid
}
}
}
const
user
=
await
preLogin
.
call
(
this
,
{
user
:
query
})
const
result
=
await
postLogin
.
call
(
this
,
{
...
...
@@ -24,6 +63,6 @@ module.exports = async function (params = {}) {
return
{
errCode
:
result
.
errCode
,
newToken
:
result
.
newToken
,
u
nie
id
u
id
:
result
.
u
id
}
}
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/external/register.js
浏览文件 @
e2445e17
const
{
preRegister
,
postRegister
}
=
require
(
'
../../lib/utils/register
'
)
const
{
EXTERNAL_DIRECT_CONNECT_PROVIDER
}
=
require
(
'
../../common/constants
'
)
/**
* 外部注册用户
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#external-register
* @param {object} params
* @param {string} params.externalUid 业务系统的用户id
* @param {string} params.nickname 昵称
* @param {string} params.gender 性别
* @param {string} params.avatar 头像
* @returns {object}
*/
module
.
exports
=
async
function
(
params
=
{})
{
const
schema
=
{
unieid
:
'
username
'
,
externalUid
:
'
string
'
,
nickname
:
{
required
:
false
,
type
:
'
nickname
'
...
...
@@ -20,7 +31,7 @@ module.exports = async function (params = {}) {
this
.
middleware
.
validate
(
params
,
schema
)
const
{
unie
id
,
externalU
id
,
avatar
,
gender
,
nickname
...
...
@@ -28,25 +39,39 @@ module.exports = async function (params = {}) {
await
preRegister
.
call
(
this
,
{
user
:
{
username
:
unieid
identities
:
{
provider
:
EXTERNAL_DIRECT_CONNECT_PROVIDER
,
uid
:
externalUid
}
}
})
const
result
=
await
postRegister
.
call
(
this
,
{
user
:
{
username
:
unieid
,
avatar
,
gender
,
nickname
,
identities
:
[
{
provider
:
EXTERNAL_DIRECT_CONNECT_PROVIDER
,
userInfo
:
{
avatar
,
gender
,
nickname
},
uid
:
externalUid
}
]
}
})
return
{
errCode
:
result
.
errCode
,
newToken
:
result
.
newToken
,
unie
id
,
externalU
id
,
avatar
,
gender
,
nickname
nickname
,
uid
:
result
.
uid
}
}
uni_modules/uni-id-pages/uniCloud/database/uni-id-users.schema.json
浏览文件 @
e2445e17
...
...
@@ -459,6 +459,14 @@
"read"
:
false
,
"write"
:
false
}
},
"identities"
:
{
"bsonType"
:
"array"
,
"description"
:
"三方平台身份信息;一个对象代表一个身份,参数支持: provider 身份源, userInfo 三方用户信息, openid 三方openid, unionid 三方unionid, uid 三方uid"
,
"permission"
:
{
"read"
:
"'READ_UNI_ID_USERS' in auth.permission"
,
"write"
:
"'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
}
}
},
"required"
:
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录