修复小程序令牌过期登录循环
This commit is contained in:
@@ -2,6 +2,7 @@ const SESSION_KEY = 'jayucloud-salon_session'
|
||||
const LOGIN_PREFERENCE_KEY = 'jayucloud_salon_login_preference'
|
||||
const PHONE_BANNER_DISMISSED_KEY = 'jayucloud_salon_phone_banner_dismissed'
|
||||
const PROFILE_PROMPT_SKIPPED_KEY = 'jayucloud_salon_profile_prompt_skipped'
|
||||
let sessionExpiredHandling = false
|
||||
|
||||
function getSession() {
|
||||
try {
|
||||
@@ -11,14 +12,25 @@ function getSession() {
|
||||
}
|
||||
}
|
||||
|
||||
function setSession(session) {
|
||||
function setSession(session, newLoginSession = false) {
|
||||
wx.setStorageSync(SESSION_KEY, session || {})
|
||||
if (newLoginSession) {
|
||||
sessionExpiredHandling = false
|
||||
}
|
||||
}
|
||||
|
||||
function clearSession() {
|
||||
wx.removeStorageSync(SESSION_KEY)
|
||||
}
|
||||
|
||||
function beginSessionExpiredHandling() {
|
||||
if (sessionExpiredHandling) {
|
||||
return false
|
||||
}
|
||||
sessionExpiredHandling = true
|
||||
return true
|
||||
}
|
||||
|
||||
function getAccessToken() {
|
||||
const session = getSession()
|
||||
return session.accessToken || session.token || ''
|
||||
@@ -47,6 +59,7 @@ module.exports = {
|
||||
getSession,
|
||||
setSession,
|
||||
clearSession,
|
||||
beginSessionExpiredHandling,
|
||||
getAccessToken,
|
||||
getLoginPreference,
|
||||
setLoginPreference,
|
||||
|
||||
Reference in New Issue
Block a user