记录真实ip
This commit is contained in:
parent
c071f2575a
commit
f88c19343f
|
@ -97,10 +97,28 @@ const actions = {
|
|||
const { data } = response
|
||||
|
||||
if (!data) {
|
||||
reject('验证失败,重新登录.')
|
||||
}
|
||||
getInfo(state.token).then(response => {
|
||||
const { data } = response
|
||||
|
||||
const { perms, name, avatar } = data
|
||||
if (!data) {
|
||||
reject('验证失败,重新登录.')
|
||||
}
|
||||
|
||||
const { perms, name, avatar } = data
|
||||
|
||||
// perms must be a non-empty array
|
||||
if (!perms || perms.length <= 0) {
|
||||
reject('没有任何权限!')
|
||||
}
|
||||
|
||||
commit('SET_PERMS', perms)
|
||||
commit('SET_NAME', name)
|
||||
commit('SET_AVATAR', avatar)
|
||||
resolve(data)
|
||||
}).catch(error => {
|
||||
reject(error)})
|
||||
}else{
|
||||
const { perms, name, avatar } = data
|
||||
|
||||
// perms must be a non-empty array
|
||||
if (!perms || perms.length <= 0) {
|
||||
|
@ -111,26 +129,11 @@ const actions = {
|
|||
commit('SET_NAME', name)
|
||||
commit('SET_AVATAR', avatar)
|
||||
resolve(data)
|
||||
}
|
||||
|
||||
|
||||
}).catch(error => {
|
||||
getInfo(state.token).then(response => {
|
||||
const { data } = response
|
||||
|
||||
if (!data) {
|
||||
reject('验证失败,重新登录.')
|
||||
}
|
||||
|
||||
const { perms, name, avatar } = data
|
||||
|
||||
// perms must be a non-empty array
|
||||
if (!perms || perms.length <= 0) {
|
||||
reject('没有任何权限!')
|
||||
}
|
||||
|
||||
commit('SET_PERMS', perms)
|
||||
commit('SET_NAME', name)
|
||||
commit('SET_AVATAR', avatar)
|
||||
resolve(data)
|
||||
}).catch(e=>{})
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
|
|
@ -27,7 +27,7 @@ class RecordMixin():
|
|||
"""
|
||||
user = request.user
|
||||
if request.method == 'GET':
|
||||
QueryRecord.objects.create(user=user,path=request.path,ip=request.META.get('REMOTE_ADDR'),method=\
|
||||
QueryRecord.objects.create(user=user,path=request.path,ip=request.META.get('HTTP_X_FORWARDED_FOR'),method=\
|
||||
request.method,search=request.query_params.get('search',None),query=request.query_params)
|
||||
|
||||
class QueryRecordListViewSet(ListModelMixin, GenericViewSet):
|
||||
|
|
Loading…
Reference in New Issue