Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: add missing token checks to request save workflow (#5436)
Prajjwol76e6c3ae2f16
diff --git a/packages/hoppscotch-common/src/components/collections/SaveRequest.vue b/packages/hoppscotch-common/src/components/collections/SaveRequest.vueindex 79a5af0a2..ff5b28b0d 100644--- a/packages/hoppscotch-common/src/components/collections/SaveRequest.vue+++ b/packages/hoppscotch-common/src/components/collections/SaveRequest.vue@@ -154,6 +154,7 @@ import { TeamWorkspace } from "~/services/workspace.service"import IconSparkle from "~icons/lucide/sparkles"import IconThumbsDown from "~icons/lucide/thumbs-down"import IconThumbsUp from "~icons/lucide/thumbs-up"+import { handleTokenValidation } from "~/helpers/handleTokenValidation";const t = useI18n()const toast = useToast()@@ -312,6 +313,9 @@ const onSelect = (pickedVal: Picked | null) => {}const saveRequestAs = async () => {+ const isValidToken = await handleTokenValidation()+ if (!isValidToken) return+if (!requestName.value) {toast.error(`${t("error.empty_req_name")}`)returndiff --git a/packages/hoppscotch-common/src/components/http/Request.vue b/packages/hoppscotch-common/src/components/http/Request.vueindex 6afce1bf9..ffc498108 100644--- a/packages/hoppscotch-common/src/components/http/Request.vue+++ b/packages/hoppscotch-common/src/components/http/Request.vue@@ -270,6 +270,7 @@ import { RESTTabService } from "~/services/tab/rest"import { getMethodLabelColor } from "~/helpers/rest/labelColoring"import { WorkspaceService } from "~/services/workspace.service"import { KernelInterceptorService } from "~/services/kernel-interceptor.service"+import { handleTokenValidation } from "~/helpers/handleTokenValidation";const t = useI18n()const interceptorService = useService(KernelInterceptorService)@@ -514,7 +515,10 @@ const cycleDownMethod = () => {}}-const saveRequest = () => {+const saveRequest = async () => {+ const isValidToken = await handleTokenValidation()+ if (!isValidToken) return+const saveCtx = tab.value.document.saveContextif (!saveCtx) {