Compare commits

...

3 Commits

Author SHA1 Message Date
ibuler
d186ae1f23 fix: 修复时间引起的bug 2020-09-14 12:41:08 +08:00
ibuler
c5defdd835 feat: 请求时刷新session age 2020-09-14 12:41:08 +08:00
Orange
40e7fcda2e fix: 修复K8S系统用户更新时令牌是必填项的问题
Closes https://github.com/jumpserver/trello/issues/276
2020-08-28 18:02:29 +08:00
3 changed files with 32 additions and 1 deletions

View File

@@ -65,3 +65,7 @@ export function logout() {
method: 'post'
})
}
export function refreshSessionIdAge() {
return getProfile()
}

View File

@@ -1,6 +1,7 @@
import axios from 'axios'
import i18n from '@/i18n/i18n'
import { getTokenFromCookie } from '@/utils/auth'
import { refreshSessionIdAge } from '@/api/users'
import { Message, MessageBox } from 'element-ui'
import store from '@/store'
@@ -88,6 +89,19 @@ export function flashErrorMsg({ response, error }) {
}
}
let timer = null
function refreshSessionAgeDelay(response) {
if (response.request.responseURL.indexOf('/users/profile/') !== -1) {
return
}
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(function() {
refreshSessionIdAge()
}, 60 * 10 * 1000)
}
// response interceptor
service.interceptors.response.use(
/**
@@ -102,6 +116,7 @@ service.interceptors.response.use(
*/
response => {
// NProgress.done()
refreshSessionAgeDelay(response)
const res = response.data
if (response.config.raw === 1) {

View File

@@ -111,7 +111,9 @@ export default {
type: 'textarea',
autosize: true
},
hidden: form => form.protocol !== 'k8s'
hidden: form => {
return form.protocol !== 'k8s'
}
},
protocol: {
rules: [
@@ -208,6 +210,16 @@ export default {
url: '/api/v1/assets/system-users/',
authHiden: false
}
},
method: {
},
mounted() {
const params = this.$route.params
const method = params.id ? 'post' : 'put'
if (method === 'post') {
this.fieldsMeta.token.rules[0].required = false
}
}
}
</script>