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

修复 退出登录为完成就刚刚本地登录状态的问题

上级 2a20666c
......@@ -43,17 +43,20 @@ export const loginSuccess = (_ : UTSJSONObject) => {
}
export const logout = () => {
export const logout = async () => {
// console.log("logout");
// 1. 已经过期就不需要调用服务端的注销接口 2.即使调用注销接口失败,不能阻塞客户端
if (uniCloud.getCurrentUserInfo().tokenExpired > Date.now()) {
const uniIdCo = uniCloud.importObject("uni-id-co", { customUI: false })
uniIdCo.logout().finally(() => {
// 调完注销接口 跳转至登录页面
uni.redirectTo({
url: "/uni_modules/uni-id-pages-x/pages/login/login"
})
})
try{
await uniIdCo.logout()
}catch(_){
//TODO handle the exception
}
// 调完注销接口 跳转至登录页面
uni.redirectTo({
url: "/uni_modules/uni-id-pages-x/pages/login/login"
})
}
uni.removeStorageSync('uni_id_token');
uni.setStorageSync('uni_id_token_expired', 0)
......@@ -98,4 +101,4 @@ export const checkPassword = (password : string) : UTSJSONObject => {
res["pass"] = passwordRegExp.test(password);
res["errMsg"] = passwordRules.getString(passwordStrength + '.errMsg');
return res
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册