Commit d8e3bbe7 authored by nano's avatar nano

fix

parent a93d5549
......@@ -188,16 +188,11 @@ export default {
setup({ dispatch, history }) {
let token = localStorage.getItem("token")
if(window.location.pathname != '/signin') {
dispatch({ type: 'preLogin', payload: { token } })
}
history.listen((a) => {
console.log(a)
})
return history.listen(({ pathname, query }) => {
console.log(pathname, query)
if(pathname == '/' || pathname == 'profiles') {
dispatch({ type: 'preLogin', payload: { token } })
}
if(pathname == 'profiles' && !token) {
history.push("/signin")
......
......@@ -7,25 +7,29 @@ let sso
let ssoString = url.searchParams.get('sso')
if (ssoString) {
sso = new URLSearchParams(Buffer.from(ssoString, 'base64').toString())
sso = new URLSearchParams(Buffer.from(ssoString, 'base64').toString())
}
export const handleSSO = (user) => {
let params = new URLSearchParams()
let url = new URL(sso.get("return_sso_url"));
for (let [key, value] of Object.entries(user)) {
params.set(key, value)
if(sso) {
let params = new URLSearchParams()
let url = new URL(sso.get("return_sso_url"));
for (let [key, value] of Object.entries(user)) {
params.set(key, value)
}
params.set("return_sso_url", sso.get("return_sso_url"))
params.set("nonce", sso.get("nonce"))
params.set("external_id", user.id)
let payload = Buffer.from(params.toString()).toString('base64')
url.searchParams.set("sso", payload)
url.searchParams.set('sig', crypto.createHmac('sha256', 'zsZv6LXHDwwtUAGa').update(payload).digest('hex'))
window.location.href = url
return true
}else {
return false
}
params.set("return_sso_url", sso.get("return_sso_url"))
params.set("nonce", sso.get("nonce"))
params.set("external_id", user.id)
let payload = Buffer.from(params.toString()).toString('base64')
url.searchParams.set("sso", payload)
url.searchParams.set('sig', crypto.createHmac('sha256', 'zsZv6LXHDwwtUAGa').update(payload).digest('hex'))
window.location.href = url
return true
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment