Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CD-CODE Web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CD-CODE team
CD-CODE Web
Commits
7bfab1ae
Commit
7bfab1ae
authored
2 years ago
by
moon
Browse files
Options
Downloads
Patches
Plain Diff
fix: expire time is .env file
parent
eb989c65
Branches
auto_logout
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
web/src/components/js/const.js
+3
-0
3 additions, 0 deletions
web/src/components/js/const.js
web/src/store/modules/User.js
+16
-22
16 additions, 22 deletions
web/src/store/modules/User.js
web/src/views/Login.vue
+2
-8
2 additions, 8 deletions
web/src/views/Login.vue
with
21 additions
and
30 deletions
web/src/components/js/const.js
+
3
−
0
View file @
7bfab1ae
...
...
@@ -13,3 +13,6 @@ export const apikey = process.env.VUE_APP_API_KEY;
// wiki apikey should be given here:
export
const
wikiApikey
=
process
.
env
.
VUE_APP_WIKI_KEY
;
// expire time
export
const
expireTime
=
process
.
env
.
VUE_APP_EXPIRE_TIME
;
This diff is collapsed.
Click to expand it.
web/src/store/modules/User.js
+
16
−
22
View file @
7bfab1ae
...
...
@@ -8,7 +8,8 @@ const state = {
expirationDate
:
null
,
didAutoLogout
:
false
,
isLoggedIn
:
false
,
lastPath
:
null
lastPath
:
null
,
expireTime
:
20000
,
};
const
mutations
=
{
...
...
@@ -16,29 +17,24 @@ const mutations = {
state
.
jwt
=
jwt
;
},
SET_USER_DATA
(
state
,
userData
)
{
state
.
userData
=
userData
;
// state.tokenExpiration
},
SET_USER_ROLE
(
state
,
userRole
)
{
state
.
userRole
=
userRole
;
},
// SET_TOKEN_EXPIRATION(state, tokenExpiration){
// console.log("in action epiration data is", tokenExpiration);
// state.expirationDate = tokenExpiration
// },
LOG_OUT
(
state
)
{
state
.
jwt
=
null
;
state
.
userData
=
null
;
state
.
userRole
=
null
;
},
setAutoLogout
(
state
){
SET_AUTO_LOGOUT
(
state
){
state
.
didAutoLogout
=
true
},
setLastPath
(
state
,
payload
){
SET_LAST_PATH
(
state
,
payload
){
state
.
lastPath
=
payload
},
SET_EXPIRE_TIME
(
state
,
expireTime
)
{
state
.
expireTime
=
expireTime
}
};
...
...
@@ -47,7 +43,8 @@ const getters = {
userData
:
(
state
)
=>
state
.
userData
,
userRole
:
(
state
)
=>
state
.
userRole
,
didAutoLogout
:
(
state
)
=>
state
.
didAutoLogout
,
getLastPath
:
(
state
)
=>
state
.
lastPath
getLastPath
:
(
state
)
=>
state
.
lastPath
,
expireTime
:
(
state
)
=>
state
.
expireTime
};
const
actions
=
{
...
...
@@ -55,7 +52,7 @@ const actions = {
localStorage
.
setItem
(
'
jwt
'
,
jwt
);
commit
(
'
SET_JWT
'
,
jwt
);
},
setUserData
({
commit
,
dispatch
},
userData
)
{
setUserData
({
commit
,
dispatch
,
state
},
userData
)
{
localStorage
.
setItem
(
'
userData
'
,
userData
);
/*
calulation of hours to millisec
...
...
@@ -63,12 +60,7 @@ const actions = {
*/
// const expiresIn = 60 * 1000
// const expiresIn = 20000
let
expiresIn
=
20000
if
(
process
.
env
.
VUE_APP_USER_EXPIRE_SEC
)
{
expiresIn
=
parseInt
(
process
.
env
.
VUE_APP_USER_EXPIRE_SEC
)
}
else
{
console
.
error
(
'
Please setup VUE_APP_USER_EXPIRE_SEC environment variable. Default expiration time is 20 seconds
'
)
}
let
expiresIn
=
state
.
expireTime
const
expirationDate
=
new
Date
().
getTime
()
+
expiresIn
localStorage
.
setItem
(
'
tokenExpiration
'
,
expirationDate
)
...
...
@@ -114,11 +106,13 @@ const actions = {
},
autoLogout
(
context
){
context
.
dispatch
(
'
logOut
'
)
context
.
commit
(
'
setAutoLogout
'
)
context
.
commit
(
'
SET_AUTO_LOGOUT
'
)
},
setLastPath
(
context
,
path
){
context
.
commit
(
'
setLastPath
'
,
path
)
context
.
commit
(
'
SET_LAST_PATH
'
,
path
)
},
setExpireTime
(
context
,
expireTime
)
{
context
.
commit
(
'
SET_EXPIRE_TIME
'
,
expireTime
)
}
};
...
...
This diff is collapsed.
Click to expand it.
web/src/views/Login.vue
+
2
−
8
View file @
7bfab1ae
...
...
@@ -156,6 +156,7 @@
</
template
>
<
script
>
let
host
=
require
(
'
@/components/js/const
'
).
apiHost
;
const
expireTime
=
parseInt
(
require
(
'
@/components/js/const
'
).
expireTime
);
export
default
{
name
:
'
Login
'
,
...
...
@@ -257,16 +258,9 @@ export default {
return
;
}
const
{
jwt
,
user
}
=
response
;
// window.localStorage.setItem('jwt', jwt);
// window.localStorage.setItem('userData', JSON.stringify(user));
this
.
$store
.
dispatch
(
'
User/setExpireTime
'
,
expireTime
);
this
.
$store
.
dispatch
(
'
User/setJwt
'
,
jwt
);
this
.
$store
.
dispatch
(
'
User/setUserData
'
,
JSON
.
stringify
(
user
));
this
.
isLoading
=
false
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment