Skip to content

Commit 47d8542

Browse files
author
piexlmax
committed
修改前端接口调用防止越权
1 parent 4172861 commit 47d8542

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

web/src/api/user.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ export const setUserInfo = (data) => {
112112
})
113113
}
114114

115+
// @Tags SysUser
116+
// @Summary 设置用户信息
117+
// @Security ApiKeyAuth
118+
// @accept application/json
119+
// @Produce application/json
120+
// @Param data body model.SysUser true "设置用户信息"
121+
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
122+
// @Router /user/setSelfInfo [put]
123+
export const setSelfInfo = (data) => {
124+
return service({
125+
url: '/user/setSelfInfo',
126+
method: 'put',
127+
data: data
128+
})
129+
}
130+
115131
// @Tags User
116132
// @Summary 设置用户权限
117133
// @Security ApiKeyAuth

web/src/store/module/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { login, getUserInfo, setUserInfo } from '@/api/user'
1+
import { login, getUserInfo, setSelfInfo } from '@/api/user'
22
import { jsonInBlacklist } from '@/api/jwt'
33
import router from '@/router/index'
44
import { ElMessage } from 'element-plus'
@@ -81,7 +81,7 @@ export const user = {
8181
}
8282
},
8383
async changeSideMode({ commit, state }, data) {
84-
const res = await setUserInfo({ sideMode: data, ID: state.userInfo.ID })
84+
const res = await setSelfInfo({ sideMode: data })
8585
if (res.code === 0) {
8686
commit('ChangeSideMode', data)
8787
ElMessage({

web/src/view/person/person.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130

131131
<script>
132132
import ChooseImg from '@/components/chooseImg/index.vue'
133-
import { setUserInfo, changePassword } from '@/api/user.js'
133+
import { setSelfInfo, changePassword } from '@/api/user.js'
134134
135135
import { mapGetters, mapMutations } from 'vuex'
136136
const path = import.meta.env.VITE_BASE_API
@@ -208,7 +208,7 @@ export default {
208208
this.$refs.chooseImg.open()
209209
},
210210
async enterImg(url) {
211-
const res = await setUserInfo({ headerImg: url, ID: this.userInfo.ID })
211+
const res = await setSelfInfo({ headerImg: url })
212212
if (res.code === 0) {
213213
this.ResetUserInfo({ headerImg: url })
214214
this.$message({
@@ -226,7 +226,7 @@ export default {
226226
this.editFlag = false
227227
},
228228
async enterEdit() {
229-
const res = await setUserInfo({ nickName: this.nickName, ID: this.userInfo.ID })
229+
const res = await setSelfInfo({ nickName: this.nickName })
230230
if (res.code === 0) {
231231
this.ResetUserInfo({ nickName: this.nickName })
232232
this.$message({

web/src/view/superAdmin/user/user.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ import { mapGetters } from 'vuex'
128128
import CustomPic from '@/components/customPic/index.vue'
129129
import ChooseImg from '@/components/chooseImg/index.vue'
130130
import warningBar from '@/components/warningBar/warningBar.vue'
131-
import { setUserInfo, resetPassword } from '@/api/user.js'
131+
import { setSelfInfo, resetPassword } from '@/api/user.js'
132132
export default {
133133
name: 'Api',
134134
components: { CustomPic, ChooseImg, warningBar },
@@ -230,7 +230,7 @@ export default {
230230
row.editFlag = true
231231
},
232232
async enterEdit(row) {
233-
const res = await setUserInfo({ nickName: row.nickName, ID: row.ID })
233+
const res = await setSelfInfo({ nickName: row.nickName })
234234
if (res.code === 0) {
235235
this.$message({
236236
type: 'success',

0 commit comments

Comments
 (0)