Browse Source

单点登录的注释

release_0.0.3
巴林闲侠 2 years ago
parent
commit
a75526b023
  1. 7
      code/web/client/src/sections/auth/containers/cross.jsx

7
code/web/client/src/sections/auth/containers/cross.jsx

@ -16,16 +16,18 @@ const Cross = ({ dispatch, actions }) => {
const { data } = e const { data } = e
if (data && data.action) { if (data && data.action) {
if (data.action == 'logout') { if (data.action == 'logout') {
// 退
preLogout() preLogout()
} else if (data.action = 'login') { } else if (data.action = 'login') {
//
localStorage.setItem('fs_iot_cross_user', JSON.stringify(data.user)) localStorage.setItem('fs_iot_cross_user', JSON.stringify(data.user))
} }
} }
} }
function storageListen (e) { function storageListen (e) {
console.log(e);
if (e.key == 'fs_iot_cross_user') { if (e.key == 'fs_iot_cross_user') {
if (!e.newValue) { if (!e.newValue) {
// 退 退
// IOT AUTH 退 // IOT AUTH 退
window.parent.postMessage({ action: 'logout' }, '*'); window.parent.postMessage({ action: 'logout' }, '*');
} }
@ -40,12 +42,15 @@ const Cross = ({ dispatch, actions }) => {
user = JSON.parse(user) user = JSON.parse(user)
const crossRslt = await dispatch(authAction.crossCheck({ token: user.token })) const crossRslt = await dispatch(authAction.crossCheck({ token: user.token }))
if (crossRslt.success && crossRslt.payload.data.cross) { if (crossRslt.success && crossRslt.payload.data.cross) {
//
window.parent.postMessage({ action: 'initUser', user: user }, '*'); window.parent.postMessage({ action: 'initUser', user: user }, '*');
} else { } else {
// 退
window.parent.postMessage({ action: 'logout' }, '*'); window.parent.postMessage({ action: 'logout' }, '*');
preLogout() preLogout()
} }
} else { } else {
//
window.parent.postMessage({ action: 'initNotice' }, '*'); window.parent.postMessage({ action: 'initNotice' }, '*');
} }
} }

Loading…
Cancel
Save