Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello_uni-id-pages
提交
9bf6dc01
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看板
提交
9bf6dc01
编写于
2月 08, 2023
作者:
C
chenruilong
3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(uni-id-co): 优化外部用户联登数据结构
上级
14112b41
变更
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
浏览文件 @
9bf6dc01
const
{
const
{
db
,
dbCmd
,
dbCmd
,
userCollection
userCollection
}
=
require
(
'
../../common/constants
'
)
}
=
require
(
'
../../common/constants
'
)
...
@@ -85,6 +84,8 @@ function getUserQueryCondition (userRecord = {}) {
...
@@ -85,6 +84,8 @@ function getUserQueryCondition (userRecord = {}) {
username
:
username
.
toLowerCase
()
username
:
username
.
toLowerCase
()
})
})
}
}
}
else
if
(
key
===
'
identities
'
)
{
queryItem
.
identities
=
dbCmd
.
elemMatch
(
value
)
}
}
condition
.
push
(
queryItem
)
condition
.
push
(
queryItem
)
}
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js
浏览文件 @
9bf6dc01
...
@@ -83,10 +83,10 @@ module.exports = async function (params = {}) {
...
@@ -83,10 +83,10 @@ module.exports = async function (params = {}) {
username
,
username
,
dcloud_appid
:
authorizedApp
,
dcloud_appid
:
authorizedApp
,
nickname
,
nickname
,
role
:
role
,
role
,
mobile
,
mobile
,
email
,
email
,
tags
:
tags
,
tags
,
status
status
}
}
...
@@ -132,7 +132,6 @@ module.exports = async function (params = {}) {
...
@@ -132,7 +132,6 @@ module.exports = async function (params = {}) {
await
userCollection
.
doc
(
uid
).
update
(
realData
)
await
userCollection
.
doc
(
uid
).
update
(
realData
)
return
{
return
{
errCode
:
0
errCode
:
0
}
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/external/index.js
浏览文件 @
9bf6dc01
module
.
exports
=
{
module
.
exports
=
{
externalRegister
:
require
(
'
./register
'
),
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
浏览文件 @
9bf6dc01
const
{
preLogin
,
postLogin
}
=
require
(
'
../../lib/utils/login
'
)
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
=
{})
{
module
.
exports
=
async
function
(
params
=
{})
{
const
schema
=
{
const
schema
=
{
unieid
:
'
username
'
uid
:
{
required
:
false
,
type
:
'
string
'
},
externalUid
:
{
required
:
false
,
type
:
'
string
'
}
}
}
this
.
middleware
.
validate
(
params
,
schema
)
this
.
middleware
.
validate
(
params
,
schema
)
const
{
const
{
unieid
uid
,
externalUid
}
=
params
}
=
params
const
user
=
await
preLogin
.
call
(
this
,
{
if
(
!
uid
&&
!
externalUid
)
{
user
:
{
throw
{
username
:
unieid
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
,
{
const
result
=
await
postLogin
.
call
(
this
,
{
...
@@ -24,6 +63,6 @@ module.exports = async function (params = {}) {
...
@@ -24,6 +63,6 @@ module.exports = async function (params = {}) {
return
{
return
{
errCode
:
result
.
errCode
,
errCode
:
result
.
errCode
,
newToken
:
result
.
newToken
,
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
浏览文件 @
9bf6dc01
const
{
preRegister
,
postRegister
}
=
require
(
'
../../lib/utils/register
'
)
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
=
{})
{
module
.
exports
=
async
function
(
params
=
{})
{
const
schema
=
{
const
schema
=
{
unieid
:
'
username
'
,
externalUid
:
'
string
'
,
nickname
:
{
nickname
:
{
required
:
false
,
required
:
false
,
type
:
'
nickname
'
type
:
'
nickname
'
...
@@ -20,7 +31,7 @@ module.exports = async function (params = {}) {
...
@@ -20,7 +31,7 @@ module.exports = async function (params = {}) {
this
.
middleware
.
validate
(
params
,
schema
)
this
.
middleware
.
validate
(
params
,
schema
)
const
{
const
{
unie
id
,
externalU
id
,
avatar
,
avatar
,
gender
,
gender
,
nickname
nickname
...
@@ -28,25 +39,39 @@ module.exports = async function (params = {}) {
...
@@ -28,25 +39,39 @@ module.exports = async function (params = {}) {
await
preRegister
.
call
(
this
,
{
await
preRegister
.
call
(
this
,
{
user
:
{
user
:
{
username
:
unieid
identities
:
{
provider
:
EXTERNAL_DIRECT_CONNECT_PROVIDER
,
uid
:
externalUid
}
}
}
})
})
const
result
=
await
postRegister
.
call
(
this
,
{
const
result
=
await
postRegister
.
call
(
this
,
{
user
:
{
user
:
{
username
:
unieid
,
avatar
,
avatar
,
gender
,
gender
,
nickname
nickname
,
identities
:
[
{
provider
:
EXTERNAL_DIRECT_CONNECT_PROVIDER
,
userInfo
:
{
avatar
,
gender
,
nickname
},
uid
:
externalUid
}
]
}
}
})
})
return
{
return
{
errCode
:
result
.
errCode
,
errCode
:
result
.
errCode
,
newToken
:
result
.
newToken
,
newToken
:
result
.
newToken
,
unie
id
,
externalU
id
,
avatar
,
avatar
,
gender
,
gender
,
nickname
nickname
,
uid
:
result
.
uid
}
}
}
}
uni_modules/uni-id-pages/uniCloud/database/uni-id-users.schema.json
浏览文件 @
9bf6dc01
...
@@ -450,7 +450,15 @@
...
@@ -450,7 +450,15 @@
"read"
:
false
,
"read"
:
false
,
"write"
:
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"
:
[]
"required"
:
[]
}
}
\ No newline at end of file
crlfe
😲
@chen1195849487
mentioned in commit
e3028713
·
2月 10, 2023
mentioned in commit
e3028713
mentioned in commit e3028713495533fbbf2863ba1115900f779a3598
开关提交列表
crlfe
😲
@chen1195849487
mentioned in commit
341c86f1
·
2月 22, 2023
mentioned in commit
341c86f1
mentioned in commit 341c86f1e4a0f0815ecad8262af8e4d3a1aac4a1
开关提交列表
crlfe
😲
@chen1195849487
mentioned in commit
e2445e17
·
2月 23, 2023
mentioned in commit
e2445e17
mentioned in commit e2445e176e998dc8b9556c758b240c0aaea1bb03
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录