⏪ Rollback server side set cookie
This commit is contained in:
parent
1130e6a574
commit
14f2bc0ee6
@ -131,7 +131,6 @@ async function readTickets({ page, itemsPerPage }: { page?: number; itemsPerPage
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
headers: { Authorization: `Bearer ${useAtk().value}` },
|
headers: { Authorization: `Bearer ${useAtk().value}` },
|
||||||
credentials: "include",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
@ -157,7 +156,6 @@ async function readEvents({ page, itemsPerPage }: { page?: number; itemsPerPage?
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
headers: { Authorization: `Bearer ${useAtk().value}` },
|
headers: { Authorization: `Bearer ${useAtk().value}` },
|
||||||
credentials: "include",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
@ -177,7 +175,6 @@ async function killTicket(item: any) {
|
|||||||
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/users/me/tickets/${item.id}`, {
|
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/users/me/tickets/${item.id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: { Authorization: `Bearer ${useAtk().value}` },
|
headers: { Authorization: `Bearer ${useAtk().value}` },
|
||||||
credentials: "include",
|
|
||||||
})
|
})
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
error.value = await res.text()
|
error.value = await res.text()
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from "vue"
|
import { onMounted, ref } from "vue"
|
||||||
import { useRoute, useRouter } from "vue-router"
|
import { useRoute, useRouter } from "vue-router"
|
||||||
|
import { setTokenSet } from "~/stores/userinfo"
|
||||||
|
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
|
|
||||||
@ -51,6 +52,8 @@ async function getToken(tk: string) {
|
|||||||
error.value = err
|
error.value = err
|
||||||
throw new Error(err)
|
throw new Error(err)
|
||||||
} else {
|
} else {
|
||||||
|
const out = await res.json()
|
||||||
|
setTokenSet(out["access_token"], out["refresh_token"])
|
||||||
error.value = null
|
error.value = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,6 @@ const panel = ref("confirm")
|
|||||||
async function tryAuthorize() {
|
async function tryAuthorize() {
|
||||||
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth/o/authorize` + window.location.search, {
|
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth/o/authorize` + window.location.search, {
|
||||||
headers: { Authorization: `Bearer ${useAtk().value}` },
|
headers: { Authorization: `Bearer ${useAtk().value}` },
|
||||||
credentials: "include",
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
@ -121,7 +120,6 @@ async function approve() {
|
|||||||
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth/o/authorize` + window.location.search, {
|
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth/o/authorize` + window.location.search, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: `Bearer ${useAtk().value}` },
|
headers: { Authorization: `Bearer ${useAtk().value}` },
|
||||||
credentials: "include",
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
|
@ -17,6 +17,15 @@ export function useAtk() {
|
|||||||
return useCookie("__hydrogen_atk", { watch: "shallow" })
|
return useCookie("__hydrogen_atk", { watch: "shallow" })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRtk() {
|
||||||
|
return useCookie("__hydrogen_rtk", { watch: "shallow" })
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setTokenSet(atk: string, rtk: string) {
|
||||||
|
useAtk().value = atk
|
||||||
|
useRtk().value = rtk
|
||||||
|
}
|
||||||
|
|
||||||
export function useLoggedInState() {
|
export function useLoggedInState() {
|
||||||
return computed(() => useAtk().value != null)
|
return computed(() => useAtk().value != null)
|
||||||
}
|
}
|
||||||
@ -34,7 +43,6 @@ export const useUserinfo = defineStore("userinfo", () => {
|
|||||||
|
|
||||||
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/users/me`, {
|
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/users/me`, {
|
||||||
headers: { Authorization: `Bearer ${useAtk().value}` },
|
headers: { Authorization: `Bearer ${useAtk().value}` },
|
||||||
credentials: "include",
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
|
Loading…
Reference in New Issue
Block a user