Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello_uni-id-pages
提交
d2a5a7af
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看板
提交
d2a5a7af
编写于
11月 10, 2022
作者:
C
chenruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: uni-id-co 支持 URL 化
上级
bd689925
变更
35
显示空白变更内容
内联
并排
Showing
35 changed file
with
129 addition
and
71 deletion
+129
-71
uni_modules/uni-id-pages/changelog.md
uni_modules/uni-id-pages/changelog.md
+4
-0
uni_modules/uni-id-pages/package.json
uni_modules/uni-id-pages/package.json
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js
...d-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js
...ges/uniCloud/cloudfunctions/uni-id-co/common/universal.js
+47
-0
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
...i-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
+6
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js
...uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js
...d-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js
+2
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js
...es/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js
+2
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js
...ages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js
+4
-4
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js
...ges/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js
+3
-3
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js
...d-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js
+12
-12
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js
...s/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js
+4
-4
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js
...ges/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js
...Cloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js
.../uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js
...niCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js
...ges/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js
+15
-15
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js
...ages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js
...niCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js
...dfunctions/uni-id-co/module/account/reset-pwd-by-email.js
+2
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js
...oudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js
+2
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js
...oud/cloudfunctions/uni-id-co/module/account/update-pwd.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js
...niCloud/cloudfunctions/uni-id-co/module/admin/add-user.js
+1
-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
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js
...loud/cloudfunctions/uni-id-co/module/login/login-by-qq.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js
.../cloudfunctions/uni-id-co/module/login/login-by-weixin.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js
...loudfunctions/uni-id-co/module/register/register-admin.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js
...niCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js
...oud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js
...Cloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js
...ud/cloudfunctions/uni-id-co/module/utils/refresh-token.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js
...oud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js
+2
-2
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js
.../cloudfunctions/uni-id-co/module/verify/create-captcha.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js
...cloudfunctions/uni-id-co/module/verify/refresh-captcha.js
+1
-1
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json
...i-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json
+1
-1
未找到文件。
uni_modules/uni-id-pages/changelog.md
浏览文件 @
d2a5a7af
## 1.0.29(2022-11-10)
-
uni-id-co 支持URL化方式请求
[
详情
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#adapter-http
)
## 1.0.28(2022-11-09)
-
uni-id-co 升级密码加密算法,支持hmac-sha256加密
[
详情
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#password-safe
)
-
uni-id-co 新增 开发者可以自定义密码加密规则
[
详情
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#custom-password-encrypt
)
-
uni-id-co 新增 支持将其他系统用户迁移至uni-id
[
详情
](
https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#move-users-to-uni-id
)
## 1.0.27(2022-10-26)
-
uni-id-co 新增 secureNetworkHandshakeByWeixin 接口,用于建立和微信小程序的安全网络连接
## 1.0.26(2022-10-18)
...
...
uni_modules/uni-id-pages/package.json
浏览文件 @
d2a5a7af
{
"id"
:
"uni-id-pages"
,
"displayName"
:
"uni-id-pages"
,
"version"
:
"1.0.2
8
"
,
"version"
:
"1.0.2
9
"
,
"description"
:
"云端一体简单、统一、可扩展的用户中心页面模版"
,
"keywords"
:
[
"用户管理"
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js
浏览文件 @
d2a5a7af
...
...
@@ -35,7 +35,8 @@ const ERROR = {
UNBIND_NOT_SUPPORTED
:
'
uni-id-unbind-not-supported
'
,
UNBIND_UNIQUE_LOGIN
:
'
uni-id-unbind-unique-login
'
,
UNBIND_PASSWORD_NOT_EXISTS
:
'
uni-id-unbind-password-not-exists
'
,
UNBIND_MOBILE_NOT_EXISTS
:
'
uni-id-unbind-mobile-not-exists
'
UNBIND_MOBILE_NOT_EXISTS
:
'
uni-id-unbind-mobile-not-exists
'
,
UNSUPPORTED_REQUEST
:
'
uni-id-unsupported-request
'
}
function
isUniIdError
(
errCode
)
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js
0 → 100644
浏览文件 @
d2a5a7af
const
{
ERROR
}
=
require
(
'
./error
'
)
function
getHttpClientInfo
()
{
const
requestId
=
this
.
getUniCloudRequestId
()
const
{
clientIP
,
userAgent
,
source
,
secretType
=
'
none
'
}
=
this
.
getClientInfo
()
const
{
clientInfo
=
{}
}
=
JSON
.
parse
(
this
.
getHttpInfo
().
body
)
return
{
...
clientInfo
,
clientIP
,
userAgent
,
source
,
secretType
,
requestId
}
}
function
getHttpUniIdToken
()
{
const
{
uniIdToken
=
''
}
=
JSON
.
parse
(
this
.
getHttpInfo
().
body
)
return
uniIdToken
}
function
verifyHttpMethod
()
{
const
{
headers
,
httpMethod
}
=
this
.
getHttpInfo
()
if
(
!
/^application
\/
json/
.
test
(
headers
[
'
content-type
'
])
||
httpMethod
.
toUpperCase
()
!==
'
POST
'
)
{
throw
{
errCode
:
ERROR
.
UNSUPPORTED_REQUEST
,
errMsg
:
'
unsupported request
'
}
}
}
function
universal
()
{
if
(
this
.
getClientInfo
().
source
===
'
http
'
)
{
verifyHttpMethod
.
call
(
this
)
this
.
getParams
()[
0
]
=
JSON
.
parse
(
this
.
getHttpInfo
().
body
).
params
this
.
getUniversalClientInfo
=
getHttpClientInfo
.
bind
(
this
)
this
.
getUniversalUniIdToken
=
getHttpUniIdToken
.
bind
(
this
)
}
else
{
this
.
getUniversalClientInfo
=
this
.
getClientInfo
this
.
getUniversalUniIdToken
=
this
.
getUniIdToken
}
}
module
.
exports
=
universal
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js
浏览文件 @
d2a5a7af
...
...
@@ -12,6 +12,7 @@ const {
isUniIdError
}
=
require
(
'
./common/error
'
)
const
middleware
=
require
(
'
./middleware/index
'
)
const
universal
=
require
(
'
./common/universal
'
)
const
{
registerAdmin
,
...
...
@@ -81,7 +82,10 @@ const {
module
.
exports
=
{
async
_before
()
{
const
clientInfo
=
this
.
getClientInfo
()
// 支持 callFunction 与 URL化
universal
.
call
(
this
)
const
clientInfo
=
this
.
getUniversalClientInfo
()
/**
* 检查clientInfo,无appId和uniPlatform时本云对象无法正常运行
* 此外需要保证用到的clientInfo字段均经过类型检查
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js
浏览文件 @
d2a5a7af
...
...
@@ -40,7 +40,8 @@ const sentence = {
'
uni-id-unbind-failed
'
:
'
Please bind first and then unbind
'
,
'
uni-id-unbind-not-supported
'
:
'
Unbinding is not supported
'
,
'
uni-id-unbind-mobile-not-exists
'
:
'
This is the only way to login at the moment, please bind your phone number and then try to unbind
'
,
'
uni-id-unbind-password-not-exists
'
:
'
Please set a password first
'
'
uni-id-unbind-password-not-exists
'
:
'
Please set a password first
'
,
'
uni-id-unsupported-request
'
:
'
Unsupported request
'
}
module
.
exports
=
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js
浏览文件 @
d2a5a7af
...
...
@@ -40,7 +40,8 @@ const sentence = {
'
uni-id-unbind-failed
'
:
'
请先绑定后再解绑
'
,
'
uni-id-unbind-not-supported
'
:
'
不支持解绑
'
,
'
uni-id-unbind-mobile-not-exists
'
:
'
这是当前唯一登录方式,请绑定手机号后再尝试解绑
'
,
'
uni-id-unbind-password-not-exists
'
:
'
请先设置密码在尝试解绑
'
'
uni-id-unbind-password-not-exists
'
:
'
请先设置密码在尝试解绑
'
,
'
uni-id-unsupported-request
'
:
'
不支持的请求方式
'
}
module
.
exports
=
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js
浏览文件 @
d2a5a7af
...
...
@@ -39,7 +39,7 @@ async function getNeedCaptcha ({
const
{
data
:
recentRecord
}
=
await
uniIdLogCollection
.
where
({
ip
:
this
.
getClientInfo
().
clientIP
,
ip
:
this
.
get
Universal
ClientInfo
().
clientIP
,
...
userIdentifier
,
type
,
create_date
:
dbCmd
.
gt
(
now
-
limitDuration
)
...
...
@@ -61,7 +61,7 @@ async function verifyCaptcha (params = {}) {
}
}
const
payload
=
await
this
.
uniCaptcha
.
verify
({
deviceId
:
this
.
getClientInfo
().
deviceId
,
deviceId
:
this
.
get
Universal
ClientInfo
().
deviceId
,
captcha
,
scene
})
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js
浏览文件 @
d2a5a7af
...
...
@@ -17,7 +17,7 @@ async function realPreLogin (params = {}) {
const
{
user
}
=
params
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
userMatched
=
await
findUser
({
userQuery
:
user
,
authorizedApp
:
appId
...
...
@@ -66,7 +66,7 @@ async function preLoginWithPassword (params = {}) {
}
=
this
.
config
const
{
clientIP
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
// 根据ip地址,密码错误次数过多,锁定登录
let
loginIPLimit
=
userRecord
.
login_ip_limit
||
[]
// 清理无用记录
...
...
@@ -79,7 +79,7 @@ async function preLoginWithPassword (params = {}) {
}
const
passwordUtils
=
new
PasswordUtils
({
userRecord
,
clientInfo
:
this
.
getClientInfo
(),
clientInfo
:
this
.
get
Universal
ClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
})
...
...
@@ -179,7 +179,7 @@ async function postLogin (params = {}) {
const
{
clientIP
,
uniIdToken
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
uid
=
user
.
_id
const
updateData
=
{
last_login_date
:
Date
.
now
(),
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js
浏览文件 @
d2a5a7af
...
...
@@ -5,11 +5,11 @@ const {
userCollection
}
=
require
(
'
../../common/constants
'
)
async
function
logout
()
{
async
function
logout
()
{
const
{
uniIdToken
,
deviceId
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
{
uid
}
=
await
this
.
uniIdCommon
.
checkToken
(
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js
浏览文件 @
d2a5a7af
...
...
@@ -5,7 +5,7 @@ const {
ERROR
}
=
require
(
'
../../common/error
'
)
function
getQQPlatform
()
{
function
getQQPlatform
()
{
const
platform
=
this
.
clientPlatform
switch
(
platform
)
{
case
'
app
'
:
...
...
@@ -18,7 +18,7 @@ function getQQPlatform() {
}
}
async
function
saveQQUserKey
({
async
function
saveQQUserKey
({
openid
,
sessionKey
,
// QQ小程序用户sessionKey
accessToken
,
// App端QQ用户accessToken
...
...
@@ -26,7 +26,7 @@ async function saveQQUserKey({
}
=
{})
{
// 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。
// 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
keyObj
=
{
dcloudAppid
:
appId
,
...
...
@@ -45,9 +45,9 @@ async function saveQQUserKey({
await
this
.
uniOpenBridge
.
setUserAccessToken
(
keyObj
,
{
access_token
:
accessToken
,
access_token_expired
:
accessTokenExpired
},
accessTokenExpired
?
Math
.
floor
((
accessTokenExpired
-
Date
.
now
())
/
1000
)
:
30
*
24
*
60
*
60
},
accessTokenExpired
?
Math
.
floor
((
accessTokenExpired
-
Date
.
now
())
/
1000
)
:
30
*
24
*
60
*
60
)
break
default
:
...
...
@@ -55,7 +55,7 @@ async function saveQQUserKey({
}
}
function
generateQQCache
({
function
generateQQCache
({
sessionKey
,
// QQ小程序用户sessionKey
accessToken
,
// App端QQ用户accessToken
accessTokenExpired
// App端QQ用户accessToken过期时间
...
...
@@ -84,11 +84,11 @@ function generateQQCache({
}
}
function
getQQOpenid
({
function
getQQOpenid
({
userRecord
}
=
{})
{
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
qqOpenidObj
=
userRecord
.
qq_openid
if
(
!
qqOpenidObj
)
{
return
...
...
@@ -96,7 +96,7 @@ function getQQOpenid({
return
qqOpenidObj
[
`
${
qqPlatform
}
_
${
appId
}
`
]
||
qqOpenidObj
[
qqPlatform
]
}
async
function
getQQCacheFallback
({
async
function
getQQCacheFallback
({
userRecord
,
key
}
=
{})
{
...
...
@@ -109,13 +109,13 @@ async function getQQCacheFallback({
return
qqCache
&&
qqCache
[
key
]
}
async
function
getQQCache
({
async
function
getQQCache
({
uid
,
userRecord
,
key
}
=
{})
{
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
if
(
!
userRecord
)
{
const
getUserRes
=
await
userCollection
.
doc
(
uid
).
get
()
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js
浏览文件 @
d2a5a7af
...
...
@@ -24,7 +24,7 @@ async function realPreRegister (params = {}) {
}
=
params
const
userMatched
=
await
findUser
({
userQuery
:
user
,
authorizedApp
:
this
.
getClientInfo
().
appId
authorizedApp
:
this
.
get
Universal
ClientInfo
().
appId
})
if
(
userMatched
.
length
>
0
)
{
throw
{
...
...
@@ -54,7 +54,7 @@ async function preRegisterWithPassword (params = {}) {
user
})
const
passwordUtils
=
new
PasswordUtils
({
clientInfo
:
this
.
getClientInfo
(),
clientInfo
:
this
.
get
Universal
ClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
})
const
{
...
...
@@ -99,7 +99,7 @@ async function postRegister (params = {}) {
clientIP
,
osName
,
uniIdToken
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
merge
(
user
,
extraData
)
...
...
@@ -163,7 +163,7 @@ async function postRegister (params = {}) {
if
(
beforeRegister
)
{
userRecord
=
await
beforeRegister
({
userRecord
,
clientInfo
:
this
.
getClientInfo
()
clientInfo
:
this
.
get
Universal
ClientInfo
()
})
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js
浏览文件 @
d2a5a7af
...
...
@@ -29,7 +29,7 @@ async function preBind ({
}
=
{})
{
const
userMatched
=
await
findUser
({
userQuery
:
bindAccount
,
authorizedApp
:
this
.
getClientInfo
().
appId
authorizedApp
:
this
.
get
Universal
ClientInfo
().
appId
})
if
(
userMatched
.
length
>
0
)
{
await
this
.
middleware
.
uniIdLog
({
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js
浏览文件 @
d2a5a7af
...
...
@@ -17,7 +17,7 @@ async function realPreUnifiedLogin (params = {}) {
user
,
type
}
=
params
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
userMatched
=
await
findUser
({
userQuery
:
user
,
authorizedApp
:
appId
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js
浏览文件 @
d2a5a7af
...
...
@@ -13,7 +13,7 @@ async function getPhoneNumber ({
}
return
uniCloud
.
getPhoneNumber
({
provider
:
'
univerify
'
,
appid
:
this
.
getClientInfo
().
appId
,
appid
:
this
.
get
Universal
ClientInfo
().
appId
,
apiKey
:
univerifyConfig
.
apiKey
,
apiSecret
:
univerifyConfig
.
apiSecret
,
// eslint-disable-next-line camelcase
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js
浏览文件 @
d2a5a7af
...
...
@@ -23,7 +23,7 @@ async function setVerifyCode ({
scene
,
code
:
code
||
getVerifyCode
(),
state
:
0
,
ip
:
this
.
getClientInfo
().
clientIP
,
ip
:
this
.
get
Universal
ClientInfo
().
clientIP
,
created_date
:
now
,
expired_date
:
now
+
expiresIn
*
1000
}
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js
浏览文件 @
d2a5a7af
...
...
@@ -12,7 +12,7 @@ const {
openDataCollection
}
=
require
(
'
../../common/constants
'
)
function
decryptWeixinData
({
function
decryptWeixinData
({
encryptedData
,
sessionKey
,
iv
...
...
@@ -37,9 +37,9 @@ function decryptWeixinData({
return
decoded
}
function
getWeixinPlatform
()
{
function
getWeixinPlatform
()
{
const
platform
=
this
.
clientPlatform
const
userAgent
=
this
.
getClientInfo
().
userAgent
const
userAgent
=
this
.
get
Universal
ClientInfo
().
userAgent
switch
(
platform
)
{
case
'
app
'
:
case
'
app-plus
'
:
...
...
@@ -54,7 +54,7 @@ function getWeixinPlatform() {
}
}
async
function
saveWeixinUserKey
({
async
function
saveWeixinUserKey
({
openid
,
sessionKey
,
// 微信小程序用户sessionKey
accessToken
,
// App端微信用户accessToken
...
...
@@ -64,7 +64,7 @@ async function saveWeixinUserKey({
// 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。
// 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
keyObj
=
{
dcloudAppid
:
appId
,
...
...
@@ -91,7 +91,7 @@ async function saveWeixinUserKey({
}
}
async
function
saveSecureNetworkCache
({
async
function
saveSecureNetworkCache
({
code
,
openid
,
unionid
,
...
...
@@ -99,7 +99,7 @@ async function saveSecureNetworkCache({
})
{
const
{
appId
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
key
=
`uni-id:
${
appId
}
:weixin-mp:code:
${
code
}
:secure-network-cache`
const
value
=
JSON
.
stringify
({
openid
,
...
...
@@ -120,7 +120,7 @@ async function saveSecureNetworkCache({
}
}
function
generateWeixinCache
({
function
generateWeixinCache
({
sessionKey
,
// 微信小程序用户sessionKey
accessToken
,
// App端微信用户accessToken
refreshToken
,
// App端微信用户refreshToken
...
...
@@ -153,11 +153,11 @@ function generateWeixinCache({
}
}
function
getWeixinOpenid
({
function
getWeixinOpenid
({
userRecord
}
=
{})
{
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
wxOpenidObj
=
userRecord
.
wx_openid
if
(
!
wxOpenidObj
)
{
return
...
...
@@ -165,7 +165,7 @@ function getWeixinOpenid({
return
wxOpenidObj
[
`
${
weixinPlatform
}
_
${
appId
}
`
]
||
wxOpenidObj
[
weixinPlatform
]
}
async
function
getWeixinCacheFallback
({
async
function
getWeixinCacheFallback
({
userRecord
,
key
}
=
{})
{
...
...
@@ -178,13 +178,13 @@ async function getWeixinCacheFallback({
return
weixinCache
&&
weixinCache
[
key
]
}
async
function
getWeixinCache
({
async
function
getWeixinCache
({
uid
,
userRecord
,
key
}
=
{})
{
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
if
(
!
userRecord
)
{
const
getUserRes
=
await
userCollection
.
doc
(
uid
).
get
()
userRecord
=
getUserRes
.
data
[
0
]
...
...
@@ -212,9 +212,9 @@ async function getWeixinCache({
})
}
async
function
getWeixinAccessToken
()
{
async
function
getWeixinAccessToken
()
{
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
cache
=
await
this
.
uniOpenBridge
.
getAccessToken
({
dcloudAppid
:
appId
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js
浏览文件 @
d2a5a7af
...
...
@@ -2,7 +2,7 @@ module.exports = async function () {
if
(
this
.
authInfo
)
{
// 多次执行auth时如果第一次成功后续不再执行
return
}
const
token
=
this
.
getUniIdToken
()
const
token
=
this
.
getUni
versalUni
IdToken
()
const
payload
=
await
this
.
uniIdCommon
.
checkToken
(
token
)
if
(
payload
.
errCode
)
{
throw
payload
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js
浏览文件 @
d2a5a7af
...
...
@@ -19,7 +19,7 @@ module.exports = async function ({
clientIP
,
deviceId
,
userAgent
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
logData
=
{
appid
:
appId
,
device_id
:
deviceId
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js
浏览文件 @
d2a5a7af
...
...
@@ -79,7 +79,7 @@ module.exports = async function (params = {}) {
userQuery
:
{
email
},
authorizedApp
:
[
this
.
getClientInfo
().
appId
]
authorizedApp
:
[
this
.
get
Universal
ClientInfo
().
appId
]
})
if
(
userMatched
.
length
===
0
)
{
throw
{
...
...
@@ -95,7 +95,7 @@ module.exports = async function (params = {}) {
passwordHash
,
version
}
=
new
PasswordUtils
({
clientInfo
:
this
.
getClientInfo
(),
clientInfo
:
this
.
get
Universal
ClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
}).
generatePasswordHash
({
password
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js
浏览文件 @
d2a5a7af
...
...
@@ -79,7 +79,7 @@ module.exports = async function (params = {}) {
userQuery
:
{
mobile
},
authorizedApp
:
[
this
.
getClientInfo
().
appId
]
authorizedApp
:
[
this
.
get
Universal
ClientInfo
().
appId
]
})
if
(
userMatched
.
length
===
0
)
{
throw
{
...
...
@@ -95,7 +95,7 @@ module.exports = async function (params = {}) {
passwordHash
,
version
}
=
new
PasswordUtils
({
clientInfo
:
this
.
getClientInfo
(),
clientInfo
:
this
.
get
Universal
ClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
}).
generatePasswordHash
({
password
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js
浏览文件 @
d2a5a7af
...
...
@@ -33,7 +33,7 @@ module.exports = async function (params = {}) {
}
=
params
const
passwordUtils
=
new
PasswordUtils
({
userRecord
,
clientInfo
:
this
.
getClientInfo
(),
clientInfo
:
this
.
get
Universal
ClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
})
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js
浏览文件 @
d2a5a7af
...
...
@@ -83,7 +83,7 @@ module.exports = async function (params = {}) {
}
}
const
passwordUtils
=
new
PasswordUtils
({
clientInfo
:
this
.
getClientInfo
(),
clientInfo
:
this
.
get
Universal
ClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
})
const
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js
浏览文件 @
d2a5a7af
...
...
@@ -107,7 +107,7 @@ module.exports = async function (params = {}) {
if
(
password
)
{
const
passwordUtils
=
new
PasswordUtils
({
clientInfo
:
this
.
getClientInfo
(),
clientInfo
:
this
.
get
Universal
ClientInfo
(),
passwordSecret
:
this
.
config
.
passwordSecret
})
const
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js
浏览文件 @
d2a5a7af
...
...
@@ -56,7 +56,7 @@ module.exports = async function (params = {}) {
}
=
params
const
{
appId
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
qqApi
=
initQQ
.
call
(
this
)
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
let
apiName
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js
浏览文件 @
d2a5a7af
...
...
@@ -44,7 +44,7 @@ module.exports = async function (params = {}) {
}
=
params
const
{
appId
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
weixinApi
=
initWeixin
.
call
(
this
)
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
let
apiName
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js
浏览文件 @
d2a5a7af
...
...
@@ -38,7 +38,7 @@ module.exports = async function (params = {}) {
}).
limit
(
1
).
get
()
if
(
getAdminRes
.
data
.
length
>
0
)
{
const
[
admin
]
=
getAdminRes
.
data
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
if
(
!
admin
.
dcloud_appid
||
(
admin
.
dcloud_appid
&&
admin
.
dcloud_appid
.
includes
(
appId
)))
{
return
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js
浏览文件 @
d2a5a7af
...
...
@@ -49,7 +49,7 @@ module.exports = async function (params = {}) {
accessTokenExpired
}
=
params
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
qqApi
=
initQQ
.
call
(
this
)
const
clientPlatform
=
this
.
clientPlatform
const
apiName
=
clientPlatform
===
'
mp-qq
'
?
'
code2Session
'
:
'
getOpenidByToken
'
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js
浏览文件 @
d2a5a7af
...
...
@@ -34,7 +34,7 @@ module.exports = async function (params = {}) {
code
}
=
params
const
weixinPlatform
=
getWeixinPlatform
.
call
(
this
)
const
appId
=
this
.
getClientInfo
().
appId
const
appId
=
this
.
get
Universal
ClientInfo
().
appId
const
weixinApi
=
initWeixin
.
call
(
this
)
const
clientPlatform
=
this
.
clientPlatform
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js
浏览文件 @
d2a5a7af
...
...
@@ -16,7 +16,7 @@ const {
*/
module
.
exports
=
async
function
()
{
const
{
uid
}
=
this
.
authInfo
const
{
appId
}
=
this
.
getClientInfo
()
const
{
appId
}
=
this
.
get
Universal
ClientInfo
()
const
qqPlatform
=
getQQPlatform
.
call
(
this
)
await
preUnBind
.
call
(
this
,
{
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js
浏览文件 @
d2a5a7af
...
...
@@ -7,7 +7,7 @@ module.exports = async function () {
token
,
tokenExpired
}
=
await
this
.
uniIdCommon
.
refreshToken
({
token
:
this
.
getUniIdToken
()
token
:
this
.
getUni
versalUni
IdToken
()
})
return
{
errCode
:
0
,
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js
浏览文件 @
d2a5a7af
...
...
@@ -25,7 +25,7 @@ async function setOpendbDevice ({
screenHeight
,
romName
,
romVersion
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
const
platform
=
this
.
clientPlatform
const
now
=
Date
.
now
()
...
...
@@ -80,7 +80,7 @@ module.exports = async function (params = {}) {
deviceId
,
appId
,
osName
}
=
this
.
getClientInfo
()
}
=
this
.
get
Universal
ClientInfo
()
let
platform
=
this
.
clientPlatform
if
(
platform
===
'
app
'
)
{
platform
+=
osName
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js
浏览文件 @
d2a5a7af
...
...
@@ -18,7 +18,7 @@ module.exports = async function (params = {}) {
}
this
.
middleware
.
validate
(
params
,
schema
)
const
deviceId
=
this
.
getClientInfo
().
deviceId
const
deviceId
=
this
.
get
Universal
ClientInfo
().
deviceId
const
{
scene
}
=
params
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js
浏览文件 @
d2a5a7af
...
...
@@ -18,7 +18,7 @@ module.exports = async function (params = {}) {
}
this
.
middleware
.
validate
(
params
,
schema
)
const
deviceId
=
this
.
getClientInfo
().
deviceId
const
deviceId
=
this
.
get
Universal
ClientInfo
().
deviceId
const
{
scene
}
=
params
...
...
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json
浏览文件 @
d2a5a7af
{
"name"
:
"uni-id-co"
,
"version"
:
"1.0.2
8
"
,
"version"
:
"1.0.2
9
"
,
"description"
:
""
,
"main"
:
"index.js"
,
"keywords"
:
[],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录