Skip to content

Commit 61ad85b

Browse files
committed
fix: fetch credentials ommitted in legacy impls
1 parent 6cc716d commit 61ad85b

File tree

6 files changed

+9
-5
lines changed

6 files changed

+9
-5
lines changed

components/set-property.vue

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export default {
7373
try {
7474
this.submitting = true
7575
const res = await fetch(this.putPath, {
76+
credentials: 'same-origin',
7677
method: 'put',
7778
body: JSON.stringify(this.getData()),
7879
headers: { 'Content-Type': 'application/json' },

components/sms-verify.vue

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default {
3030
if (!this.number) return
3131
try {
3232
const res = await fetch('/api/sms-code', {
33+
credentials: 'same-origin',
3334
method: 'put',
3435
body: JSON.stringify({ number: this.number, type: this.type }),
3536
headers: { 'Content-Type': 'application/json' },

pages/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default {
6363
const avatar = ctx.avatarFromName(avatarName)
6464
return { notLoggedIn: false, nickname, kredit, avatar, keeerId }
6565
} else {
66-
const res = await fetch('/api/user-information').then(res => res.json())
66+
const res = await fetch('/api/user-information', { credentials: 'same-origin' }).then(res => res.json())
6767
if (res.status !== 0) return notLoggedIn
6868
else {
6969
const { nickname, kredit, avatar, keeerId } = res.result
@@ -77,7 +77,7 @@ export default {
7777
methods: {
7878
async logout () {
7979
try {
80-
const res = await fetch('/api/token?set-cookie=true', { method: 'delete' }).then(res => res.json())
80+
const res = await fetch('/api/token?set-cookie=true', { method: 'delete', credentials: 'same-origin' }).then(res => res.json())
8181
if (res.status !== 0) this.snackbar(res.message || '未知错误')
8282
else {
8383
this.snackbar(res.message || '您已经成功退出登录')

pages/login.vue

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export default {
163163
this.busy = true
164164
try {
165165
const res = await fetch('/api/token?set-cookie=true', {
166+
credentials: 'same-origin',
166167
method: 'put',
167168
headers: { Authorization: `Basic ${btoa(`${this.identity}:${this.password}`)}` },
168169
}).then(res => res.json())
@@ -182,6 +183,7 @@ export default {
182183
try {
183184
const { identity: number, code, password } = this
184185
const res = await fetch('/api/user?set-cookie=true', {
186+
credentials: 'same-origin',
185187
method: 'put',
186188
body: JSON.stringify({ number, code, password }),
187189
headers: { 'Content-Type': 'application/json' },

pages/recharge-cashier.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default {
4545
async poll () {
4646
console.log('New poll @ ', this.pollUrl)
4747
try {
48-
const res = await fetch(this.pollUrl).then(res => res.json())
48+
const res = await fetch(this.pollUrl, { credentials: 'same-origin' }).then(res => res.json())
4949
if (res.code === 'ETIMEOUT') {
5050
this.blur = false
5151
return this.repoll()

pages/recharge.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default {
7070
const { nickname } = ctx.state.user.options
7171
return { notLoggedIn: false, nickname }
7272
} else {
73-
const res = await fetch('/api/user-information').then(res => res.json())
73+
const res = await fetch('/api/user-information', { credentials: 'same-origin' }).then(res => res.json())
7474
if (res.status !== 0) return notLoggedIn
7575
else {
7676
const { nickname } = res.result
@@ -90,7 +90,7 @@ export default {
9090
if (amount > 100000) return this.snackbar('充值金额过大,系统无法处理')
9191
const url = new URL('/api/recharge-order', location.href)
9292
url.search = new URLSearchParams({ amount })
93-
const order = await fetch(url, { method: 'put' }).then(res => res.json())
93+
const order = await fetch(url, { method: 'put', credentials: 'same-origin' }).then(res => res.json())
9494
if (order.status !== 0) return this.snackbar(order.message || '无法创建请求')
9595
const { result } = order
9696
if (/^https?:\/\//.test(result)) location = result

0 commit comments

Comments
 (0)