提交 bc3dcf06 编写于 作者: DCloud_JSON's avatar DCloud_JSON

- 新增逻辑:调用uni-id-cf的logout接口后刷新设备信息中token的有效期 -...

- 新增逻辑:调用uni-id-cf的logout接口后刷新设备信息中token的有效期 - 修复某些情况下前端执行logout没调用uniID.logout的问题 - 修复某些情况下报push_clientid未定义的问题
上级 f6647360
## 1.1.30(2022-01-26)
- 新增逻辑:调用uni-id-cf的logout接口后刷新设备信息中token的有效期
- 修复某些情况下前端执行logout没调用uniID.logout的问题
- 修复某些情况下报push_clientid未定义的问题
## 1.1.29(2022-01-25)
- 保存`uni_id_token``storage`改用异步方法,方便通过拦截器执行`token`更新后的操作
- 新增通过拦截器监听`uni_id_token`更新,调用云函数刷新刷新设备信息token有效期的API `renewDeviceTokenExpired`
......
......@@ -120,6 +120,18 @@ export default async function() {
let oldToken = uni.getStorageSync('uni_id_token')
if(oldToken.length){
console.log('监听到token更新,就刷新push_clientid的有效期');
// #ifdef APP-PLUS
let push_clientid;
try {
push_clientid = plus.push.getClientInfo().clientid
} catch (e) {
uni.showModal({
content: '获取推送标识失败。如果你的应用不需要推送功能,请注释掉本代码块',
showCancel: false,
confirmText: "好的"
});
console.log(e)
}
uniCloud.callFunction({
name:'uni-id-cf',
data:{
......@@ -130,6 +142,7 @@ export default async function() {
console.log(e);
}
})
// #endif
}
}
// console.log('interceptor-complete', args)
......@@ -475,8 +488,7 @@ async function getDeviceInfo() {
idfa = plus.storage.getItem('idfa') || '', //idfa有需要的用户在应用首次启动时自己获取存储到storage中
vendor = plus.device.vendor;
try {
deviceInfo.push_clientid = uni.getStorageSync('cid') //先都走在线
// deviceInfo.push_clientid = plus.push.getClientInfo().clientid
deviceInfo.push_clientid = plus.push.getClientInfo().clientid
} catch (e) {
uni.showModal({
content: '获取推送标识失败。如果你的应用不需要推送功能,请注释掉本代码块',
......@@ -492,8 +504,5 @@ async function getDeviceInfo() {
vendor
});
// #endif
// #ifndef APP-PLUS
deviceInfo.push_clientid = uni.getStorageSync('cid')
// #endif
return deviceInfo
}
\ No newline at end of file
{
"id": "uni-starter",
"displayName": "uni-starter",
"version": "1.1.29",
"version": "1.1.30",
"description": "云端一体应用快速开发基本项目模版",
"keywords": [
"login",
......
......@@ -23,7 +23,7 @@
<script>
import {
mapMutations
mapActions
} from 'vuex';
export default {
data() {
......@@ -37,7 +37,7 @@
})
},
methods: {
...mapMutations({
...mapActions({
logout: 'user/logout'
}),
cancel(){
......
......@@ -34,7 +34,8 @@
import pushServer from './dc-push/push.js';
import {
mapMutations,
mapGetters
mapGetters,
mapActions
} from 'vuex';
export default {
data() {
......@@ -81,7 +82,7 @@
//#endif
},
methods: {
...mapMutations({
...mapActions({
logout: 'user/logout'
}),
toEdit() {
......@@ -188,20 +189,9 @@
confirmText: this.$t('settings.confirmText'),
success: res => {
if (res.confirm) {
uni.showLoading({
mask: true
});
uniCloud.callFunction({
name:'uni-id-cf',
data:{action:'logout'},
complete: (e) => {
console.log(e);
this.logout();
uni.hideLoading()
this.logout()
uni.navigateBack();
}
})
}
},
fail: () => {},
complete: () => {}
......
......@@ -44,7 +44,18 @@ let state = {
}
},
actions = {
logout(context){
uni.showLoading({mask:true})
uniCloud.callFunction({
name:'uni-id-cf',
data:{action:'logout'},
complete: (e) => {
console.log(e);
context.commit('logout')
uni.hideLoading()
}
})
}
}
export default {
namespaced: true,
......
## 1.0.13(2022-01-26)
新增逻辑:调用logout接口后刷新设备信息中token的有效期
## 1.0.12(2022-01-24)
- 优化设备信息存储逻辑
- 新增刷新设备信息token有效期的API `renewDeviceTokenExpired`
......
{
"id": "uni-id-cf",
"displayName": "uni-id-cf",
"version": "1.0.12",
"version": "1.0.13",
"description": "封装uni-id常用接口的云函数,快速实现简单、统一、可扩展的用户管理功能",
"keywords": [
"uni-id-cf",
......
......@@ -114,16 +114,16 @@ exports.main = async (event, context) => {
console.log(context.DEVICEID);
//避免重复新增设备信息,先判断是否已存在
let getDeviceRes = await deviceDB.where({
device_id: context.DEVICEID
"device_id": context.DEVICEID
}).get()
if (getDeviceRes.data.length == 0) {
await addDeviceInfo(res)
} else {
await deviceDB.where({
device_id: context.DEVICEID,
"device_id": context.DEVICEID,
}).update({
...deviceInfo,
tokenExpired: res.tokenExpired,
"tokenExpired": res.tokenExpired,
"user_id": res.uid,
"device_id": context.DEVICEID,
"ua": context.CLIENTUA,
......@@ -179,16 +179,14 @@ exports.main = async (event, context) => {
let res = {}
switch (action) { //根据action的值执行对应的操作
case 'renewDeviceTokenExpired':
let aa = await deviceDB.where({
user_id: params.uid,
return await deviceDB.where({
"user_id": params.uid,
"device_id": context.DEVICEID
}).update({
user_id: params.uid,
push_clientid: params.push_clientid,
"user_id": params.uid,
"push_clientid": params.push_clientid,
tokenExpired
})
console.log(aa);
return aa
break;
case 'refreshSessionKey':
let getSessionKey = await uniID.code2SessionWeixin({
......@@ -398,6 +396,11 @@ exports.main = async (event, context) => {
break;
case 'logout':
res = await uniID.logout(uniIdToken)
await deviceDB.where({
"device_id": context.DEVICEID,
}).update({
"tokenExpired": Date.now()
})
break;
case 'sendSmsCode':
/* -开始- 测试期间,为节约资源。统一虚拟短信验证码为: 123456;开启以下代码块即可 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册