mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 14:50:25 +08:00
登录页尝试使用csrf校验
This commit is contained in:
27
web/public/js/components/common/csrf-token.js
Normal file
27
web/public/js/components/common/csrf-token.js
Normal file
@@ -0,0 +1,27 @@
|
||||
Vue.component("csrf-token", {
|
||||
created: function () {
|
||||
this.refreshToken()
|
||||
},
|
||||
mounted: function () {
|
||||
let that = this
|
||||
this.$refs.token.form.addEventListener("submit", function () {
|
||||
that.refreshToken()
|
||||
})
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
token: ""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
refreshToken: function () {
|
||||
let that = this
|
||||
Tea.action("/csrf/token")
|
||||
.get()
|
||||
.success(function (resp) {
|
||||
that.token = resp.data.token
|
||||
})
|
||||
}
|
||||
},
|
||||
template: `<input type="hidden" name="csrfToken" :value="token" ref="token"/>`
|
||||
})
|
||||
Reference in New Issue
Block a user