Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
hrs_app_h5
/
bill
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0e8d4466
authored
May 06, 2020
by
展昭
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
da373d1e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
53 deletions
public/favicon.ico
src/router/index.js
src/views/OidcCallback.vue
public/favicon.ico
View file @
0e8d4466
No preview for this file type
src/router/index.js
View file @
0e8d4466
...
...
@@ -23,15 +23,15 @@ const router = new VueRouter({
component
:
()
=>
import
(
"@/views/test.vue"
)
}
],
scrollBehavior
(
to
,
from
,
savedPosition
)
{
scrollBehavior
(
to
,
from
,
savedPosition
)
{
return
{
x
:
0
,
y
:
0
}
}
})
//自动登录
function
autoLogin
(
payload
=
{
autoCode
,
redirectPath
})
{
store
.
dispatch
(
"authenticateOidc"
,{
options
:
{
extraQueryParams
:{
function
autoLogin
(
payload
=
{
autoCode
,
redirectPath
})
{
store
.
dispatch
(
"authenticateOidc"
,
{
options
:
{
extraQueryParams
:
{
authcode
:
payload
.
autoCode
},
redirectPath
:
payload
.
redirectPath
...
...
@@ -41,12 +41,12 @@ function autoLogin(payload = {autoCode, redirectPath}){
const
loginStorage
=
localStorage
;
const
autoLoginParamsKey
=
"autoLoginParams"
;
function
setAutoLogin
(
payload
=
{
autoCode
,
redirectPath
})
{
loginStorage
.
setItem
(
autoLoginParamsKey
,
JSON
.
stringify
(
payload
))
function
setAutoLogin
(
payload
=
{
autoCode
,
redirectPath
})
{
loginStorage
.
setItem
(
autoLoginParamsKey
,
JSON
.
stringify
(
payload
))
}
function
getAutoLoginParams
(){
function
getAutoLoginParams
()
{
const
paramStr
=
loginStorage
.
getItem
(
autoLoginParamsKey
);
if
(
!!
paramStr
)
{
if
(
!!
paramStr
)
{
loginStorage
.
removeItem
(
autoLoginParamsKey
);
return
JSON
.
parse
(
paramStr
);
}
...
...
@@ -54,53 +54,50 @@ function getAutoLoginParams(){
}
//如果有登录参数则优先登录
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
const
autoLoginParams
=
getAutoLoginParams
();
if
(
autoLoginParams
)
{
if
(
autoLoginParams
)
{
autoLogin
(
autoLoginParams
);
}
else
{
}
else
{
next
();
}
})
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
const
authcode
=
to
.
query
.
authc
ode
;
if
(
!!
authcode
)
{
var
toPath
=
to
.
path
||
"/"
;
for
(
let
key
in
to
.
query
)
{
if
(
key
==
'authcode'
)
{
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
const
authcode
=
to
.
query
.
authC
ode
;
if
(
!!
authcode
)
{
var
toPath
=
to
.
path
||
"/"
;
for
(
let
key
in
to
.
query
)
{
if
(
key
==
'authcode'
)
{
continue
;
}
toPath
+=
toPath
.
indexOf
(
"?"
)
>-
1
?
"&"
:
"?"
;
toPath
+=
`
${
key
}
=
${
to
.
query
}
`
;
toPath
+=
toPath
.
indexOf
(
"?"
)
>
-
1
?
"&"
:
"?"
;
toPath
+=
`
${
key
}
=
${
to
.
query
}
`
;
}
const
userId
=
to
.
query
.
userid
||
to
.
query
.
userId
;
const
isAuth
=
store
.
getters
.
oidcIsAuthenticated
;
console
.
log
(
isAuth
)
// if(isAuth){
store
.
dispatch
(
"getOidcUser"
).
then
(
oidcUser
=>
{
if
(
oidcUser
){
//如果登录用户与当前登录用户不匹配,则保存登录参数,退出
if
(
oidcUser
.
profile
.
sub
!=
userId
){
setAutoLogin
({
autoCode
:
authcode
,
redirectPath
:
toPath
})
store
.
dispatch
(
"signOutOidc"
)
}
else
{
next
()
}
}
else
{
autoLogin
({
autoCode
:
authcode
,
redirectPath
:
toPath
})
}
}).
catch
(()
=>
{
autoLogin
({
autoCode
:
authcode
,
redirectPath
:
toPath
})
});
}
else
{
store
.
dispatch
(
"getOidcUser"
).
then
(
oidcUser
=>
{
console
.
log
(
'oidcUser='
,
oidcUser
);
if
(
oidcUser
)
{
//如果登录用户与当前登录用户不匹配,则保存登录参数,退出
if
(
oidcUser
.
profile
.
sub
!=
userId
)
{
setAutoLogin
({
autoCode
:
authcode
,
redirectPath
:
toPath
})
store
.
dispatch
(
"signOutOidc"
)
}
else
{
next
()
}
}
else
{
autoLogin
({
autoCode
:
authcode
,
redirectPath
:
toPath
})
}
}).
catch
(()
=>
{
autoLogin
({
autoCode
:
authcode
,
redirectPath
:
toPath
})
});
}
else
{
next
()
}
})
router
.
beforeEach
(
vuexOidcCreateRouterMiddleware
(
store
));
...
...
src/views/OidcCallback.vue
View file @
0e8d4466
...
...
@@ -64,17 +64,17 @@ export default {
this
.
oidcSignInCallback
()
.
then
(
redirectPath
=>
{
console
.
log
(
2
,
redirectPath
);
this
.
getOidcUser
()
.
then
(
user
=>
{
//
this.getOidcUser()
//
.then(user => {
let
urlsearch
=
redirectPath
.
split
(
"?"
)[
1
];
let
appid
=
this
.
getQueryString
(
urlsearch
,
"appid"
);
this
.
getToken
(
user
.
access_token
,
appid
,
redirectPath
);
})
.
catch
(
err
=>
{
console
.
log
(
"err="
,
err
);
});
//
this.$router.push(redirectPath);
//
let urlsearch = redirectPath.split("?")[1];
//
let appid = this.getQueryString(urlsearch, "appid");
//
this.getToken(user.access_token, appid, redirectPath);
//
})
//
.catch(err => {
//
console.log("err=", err);
//
});
this
.
$router
.
push
(
redirectPath
);
})
.
catch
(
err
=>
{
console
.
error
(
err
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment