Cookies v SSR
This commit is contained in:
@@ -29,6 +29,7 @@ module.exports = configure(function (ctx) {
|
|||||||
// --> boot files are part of "main.js"
|
// --> boot files are part of "main.js"
|
||||||
// https://v2.quasar.dev/quasar-cli/boot-files
|
// https://v2.quasar.dev/quasar-cli/boot-files
|
||||||
boot: [
|
boot: [
|
||||||
|
"cookies",
|
||||||
"axios",
|
"axios",
|
||||||
"apollo",
|
"apollo",
|
||||||
"chartJs"
|
"chartJs"
|
||||||
@@ -109,6 +110,7 @@ module.exports = configure(function (ctx) {
|
|||||||
|
|
||||||
// Quasar plugins
|
// Quasar plugins
|
||||||
plugins: [
|
plugins: [
|
||||||
|
'Cookies',
|
||||||
'Dialog',
|
'Dialog',
|
||||||
'Meta',
|
'Meta',
|
||||||
'Notify'
|
'Notify'
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {createUploadLink} from "apollo-upload-client";
|
|||||||
const handleRefreshToken = (store, router, forward, operation) => {
|
const handleRefreshToken = (store, router, forward, operation) => {
|
||||||
if (!operation.query?._refreshUnauthorizedUser) return;
|
if (!operation.query?._refreshUnauthorizedUser) return;
|
||||||
|
|
||||||
|
console.log("refreshing token, ", operation.query);
|
||||||
return fromPromise(useUserStore(store).refreshAccessToken()
|
return fromPromise(useUserStore(store).refreshAccessToken()
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
Notify.create(warningObject("Tvoje přihlášení vypřešlo. Přihlaš se prosím znovu."));
|
Notify.create(warningObject("Tvoje přihlášení vypřešlo. Přihlaš se prosím znovu."));
|
||||||
@@ -34,6 +35,7 @@ export const apolloWrapper = {};
|
|||||||
export default (({store, router}) => {
|
export default (({store, router}) => {
|
||||||
const uploadLink = createUploadLink({
|
const uploadLink = createUploadLink({
|
||||||
uri: process.env.API_URL + '/graphql',
|
uri: process.env.API_URL + '/graphql',
|
||||||
|
credentials: 'include'
|
||||||
})
|
})
|
||||||
|
|
||||||
const authLink = new ApolloLink((operation, forward) => {
|
const authLink = new ApolloLink((operation, forward) => {
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import {Cookies} from 'quasar'
|
||||||
|
import {boot} from "quasar/wrappers";
|
||||||
|
|
||||||
|
let cookies = Cookies;
|
||||||
|
export default boot(({ssrContext}) => {
|
||||||
|
cookies = process.env.SERVER ? Cookies.parseSSR(ssrContext) : Cookies
|
||||||
|
});
|
||||||
|
|
||||||
|
export {cookies}
|
||||||
@@ -34,18 +34,24 @@
|
|||||||
</q-drawer>
|
</q-drawer>
|
||||||
|
|
||||||
<q-page-container>
|
<q-page-container>
|
||||||
<BreadcrumbsNavigation :items="breadcrumbs" v-if="breadcrumbs !== null"/>
|
<BreadcrumbsNavigation :items="breadcrumbs || []"/>
|
||||||
<BreadcrumbsSkeleton v-if="breadcrumbs === null" />
|
|
||||||
<div class="q-mx-md q-my-md">
|
<div class="q-mx-md q-my-md">
|
||||||
<router-view/>
|
<router-view/>
|
||||||
</div>
|
</div>
|
||||||
</q-page-container>
|
</q-page-container>
|
||||||
</q-layout>
|
</q-layout>
|
||||||
</template>
|
</template>
|
||||||
|
<script>
|
||||||
<script setup>
|
|
||||||
import {onMounted, ref} from 'vue'
|
|
||||||
import {useUserStore} from "stores/User";
|
import {useUserStore} from "stores/User";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
preFetch() {
|
||||||
|
return useUserStore().fetchLoggedUserDetail({refresh: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script setup>
|
||||||
|
import {ref} from 'vue'
|
||||||
import {storeToRefs} from "pinia";
|
import {storeToRefs} from "pinia";
|
||||||
import BreadcrumbsNavigation from "components/navigation/BreadcrumbsNavigation.vue";
|
import BreadcrumbsNavigation from "components/navigation/BreadcrumbsNavigation.vue";
|
||||||
import {useAppStore} from "stores/App";
|
import {useAppStore} from "stores/App";
|
||||||
@@ -55,7 +61,6 @@ import {successObject} from "src/composables/dialog";
|
|||||||
import SidebarNavigation from "components/navigation/SidebarNavigation.vue";
|
import SidebarNavigation from "components/navigation/SidebarNavigation.vue";
|
||||||
import TopMenuButton from "components/navigation/TopMenuButton.vue";
|
import TopMenuButton from "components/navigation/TopMenuButton.vue";
|
||||||
import {metaData} from "src/composables/meta";
|
import {metaData} from "src/composables/meta";
|
||||||
import BreadcrumbsSkeleton from "components/navigation/BreadcrumbsSkeleton.vue";
|
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const $router = useRouter();
|
const $router = useRouter();
|
||||||
@@ -70,9 +75,6 @@ const toggleLeftDrawer = () => {
|
|||||||
leftDrawerOpen.value = !leftDrawerOpen.value
|
leftDrawerOpen.value = !leftDrawerOpen.value
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
useUserStore().fetchLoggedUserDetail({refresh: true});
|
|
||||||
})
|
|
||||||
const {isQueryRunning, user} = storeToRefs(useUserStore());
|
const {isQueryRunning, user} = storeToRefs(useUserStore());
|
||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
|
|||||||
@@ -32,10 +32,17 @@
|
|||||||
</q-layout>
|
</q-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {useUserStore} from "stores/User";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
preFetch() {
|
||||||
|
return useUserStore().fetchLoggedUserDetail({refresh: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<script setup>
|
<script setup>
|
||||||
import {storeToRefs} from "pinia";
|
import {storeToRefs} from "pinia";
|
||||||
import {useUserStore} from "stores/User";
|
|
||||||
import {onMounted} from "vue";
|
|
||||||
import {useAppStore} from "stores/App";
|
import {useAppStore} from "stores/App";
|
||||||
import BreadcrumbsNavigation from "components/navigation/BreadcrumbsNavigation.vue";
|
import BreadcrumbsNavigation from "components/navigation/BreadcrumbsNavigation.vue";
|
||||||
import AvatarFromPhoto from "components/avatars/AvatarFromPhoto.vue";
|
import AvatarFromPhoto from "components/avatars/AvatarFromPhoto.vue";
|
||||||
@@ -43,14 +50,4 @@ import BreadcrumbsSkeleton from "components/navigation/BreadcrumbsSkeleton.vue";
|
|||||||
|
|
||||||
const {pageTitle, breadcrumbs} = storeToRefs(useAppStore());
|
const {pageTitle, breadcrumbs} = storeToRefs(useAppStore());
|
||||||
const loggedUser = storeToRefs(useUserStore()).user;
|
const loggedUser = storeToRefs(useUserStore()).user;
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
useUserStore().fetchLoggedUserDetail({refresh: false});
|
|
||||||
|
|
||||||
if (loggedUser || useUserStore().hasAccessToken()) {
|
|
||||||
// poll once per 5 minutes to keep access token active
|
|
||||||
setInterval(() => useUserStore().fetchLoggedUserDetail({refresh: false}), 5 * 60 * 1000);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,22 +1,11 @@
|
|||||||
<script>
|
|
||||||
import {useAircraftsStore} from "stores/Aircrafts";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
preFetch({currentRoute}) {
|
|
||||||
return useAircraftsStore().fetchPublicDetail(currentRoute.params.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {useRouter} from "vue-router";
|
import {useRoute, useRouter} from "vue-router";
|
||||||
import {useMeta, useQuasar} from "quasar";
|
import {useMeta, useQuasar} from "quasar";
|
||||||
import AircraftDetailSkeleton from "components/aircrafts/skeletons/AircraftDetailSkeleton.vue";
|
import AircraftDetailSkeleton from "components/aircrafts/skeletons/AircraftDetailSkeleton.vue";
|
||||||
import {confirmObject, successObject} from "src/composables/dialog";
|
|
||||||
import {useAppStore} from "stores/App";
|
import {useAppStore} from "stores/App";
|
||||||
import FlightsList from "components/flights/FlightsList.vue";
|
import FlightsList from "components/flights/FlightsList.vue";
|
||||||
import {storeToRefs} from "pinia";
|
import {storeToRefs} from "pinia";
|
||||||
import {computed, onMounted, watch} from "vue";
|
import {onMounted, onServerPrefetch} from "vue";
|
||||||
import {metaData} from "src/composables/meta";
|
import {metaData} from "src/composables/meta";
|
||||||
import PhotoGallery from "components/photos/PhotoGallery.vue";
|
import PhotoGallery from "components/photos/PhotoGallery.vue";
|
||||||
import ContentCard from "components/ContentCard.vue";
|
import ContentCard from "components/ContentCard.vue";
|
||||||
@@ -26,18 +15,22 @@ import {usePhotosStore} from "stores/Photos";
|
|||||||
import {useFlightsStore} from "stores/Flights";
|
import {useFlightsStore} from "stores/Flights";
|
||||||
import FlightsListSkeleton from "components/flights/skeletons/FlightsListSkeleton.vue";
|
import FlightsListSkeleton from "components/flights/skeletons/FlightsListSkeleton.vue";
|
||||||
import BasicInfoBanner from "components/banners/BasicInfoBanner.vue";
|
import BasicInfoBanner from "components/banners/BasicInfoBanner.vue";
|
||||||
|
import {useAircraftsStore} from "stores/Aircrafts";
|
||||||
|
import PhotoGallerySkeleton from "components/photos/skeletons/PhotoGallerySkeleton.vue";
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const $router = useRouter();
|
const $router = useRouter();
|
||||||
|
const $route = useRoute();
|
||||||
|
|
||||||
|
onServerPrefetch(() => {
|
||||||
|
return useAircraftsStore().fetchPublicDetail($route.params.id);
|
||||||
|
});
|
||||||
|
|
||||||
const loggedUser = storeToRefs(useUserStore()).user;
|
const loggedUser = storeToRefs(useUserStore()).user;
|
||||||
const {aircraft, isQueryRunning} = storeToRefs(useAircraftsStore());
|
const {aircraft, isQueryRunning} = storeToRefs(useAircraftsStore());
|
||||||
const {photos, isQueryRunning: arePhotosLoading} = storeToRefs(usePhotosStore());
|
const {photos, isQueryRunning: arePhotosLoading} = storeToRefs(usePhotosStore());
|
||||||
const {flights, isQueryRunning: areFlightsLoading} = storeToRefs(useFlightsStore());
|
const {flights, isQueryRunning: areFlightsLoading} = storeToRefs(useFlightsStore());
|
||||||
|
|
||||||
usePhotosStore().fetchPublic({aircraftId: aircraft.value.id});
|
|
||||||
useFlightsStore().fetchPublic({aircraftId: aircraft.value.id})
|
|
||||||
|
|
||||||
useAppStore().setPageTitle(aircraft.value.callSign);
|
useAppStore().setPageTitle(aircraft.value.callSign);
|
||||||
useMeta(() => metaData({
|
useMeta(() => metaData({
|
||||||
title: aircraft.value.callSign,
|
title: aircraft.value.callSign,
|
||||||
@@ -49,12 +42,17 @@ useMeta(() => metaData({
|
|||||||
aircraft.value.organization?.name,
|
aircraft.value.organization?.name,
|
||||||
aircraft.value.manufacturer
|
aircraft.value.manufacturer
|
||||||
],
|
],
|
||||||
description: aircraft.value.description
|
description: aircraft.value.description || `Detail letadla ${aircraft.value.callSign}.`
|
||||||
}));
|
}));
|
||||||
useAppStore().setBreadcrumbs([
|
useAppStore().setBreadcrumbs([
|
||||||
{label: "Polétání.cz", to: {name: "homepage"}},
|
{label: "Polétání.cz", to: {name: "homepage"}},
|
||||||
{label: aircraft.value.callSign}
|
{label: aircraft.value.callSign}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
usePhotosStore().fetchPublic({aircraftId: aircraft.value.id});
|
||||||
|
useFlightsStore().fetchPublic({aircraftId: aircraft.value.id})
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -66,7 +64,8 @@ useAppStore().setBreadcrumbs([
|
|||||||
<q-card-section>
|
<q-card-section>
|
||||||
<AircraftInfo :aircraft="aircraft"/>
|
<AircraftInfo :aircraft="aircraft"/>
|
||||||
|
|
||||||
<PhotoGallery :photos="photos"/>
|
<PhotoGallerySkeleton v-if="arePhotosLoading && !photos.length"/>
|
||||||
|
<PhotoGallery :photos="photos" v-else/>
|
||||||
|
|
||||||
<h3>Lety</h3>
|
<h3>Lety</h3>
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,3 @@
|
|||||||
<script>
|
|
||||||
import {usePointsOfInterestStore} from "stores/PointsOfInterest";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
preFetch({currentRoute, store}) {
|
|
||||||
return usePointsOfInterestStore(store).fetchPublicDetail(currentRoute.params.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {storeToRefs} from "pinia";
|
import {storeToRefs} from "pinia";
|
||||||
import {usePhotosStore} from "stores/Photos";
|
import {usePhotosStore} from "stores/Photos";
|
||||||
@@ -21,6 +11,15 @@ import {useMeta} from "quasar";
|
|||||||
import {metaData} from "src/composables/meta";
|
import {metaData} from "src/composables/meta";
|
||||||
import FlightsListSkeleton from "components/flights/skeletons/FlightsListSkeleton.vue";
|
import FlightsListSkeleton from "components/flights/skeletons/FlightsListSkeleton.vue";
|
||||||
import BasicInfoBanner from "components/banners/BasicInfoBanner.vue";
|
import BasicInfoBanner from "components/banners/BasicInfoBanner.vue";
|
||||||
|
import {usePointsOfInterestStore} from "stores/PointsOfInterest";
|
||||||
|
import {onServerPrefetch} from "vue";
|
||||||
|
import {useRoute} from "vue-router";
|
||||||
|
|
||||||
|
const $route = useRoute();
|
||||||
|
|
||||||
|
onServerPrefetch(() => {
|
||||||
|
return usePointsOfInterestStore().fetchPublicDetail($route.params.id);
|
||||||
|
});
|
||||||
|
|
||||||
const {pointOfInterest, isQueryRunning} = storeToRefs(usePointsOfInterestStore());
|
const {pointOfInterest, isQueryRunning} = storeToRefs(usePointsOfInterestStore());
|
||||||
const {photos, isQueryRunning: arePhotosLoading} = storeToRefs(usePhotosStore());
|
const {photos, isQueryRunning: arePhotosLoading} = storeToRefs(usePhotosStore());
|
||||||
|
|||||||
@@ -2,18 +2,17 @@
|
|||||||
import {useCopilotsStore} from "stores/Copilots";
|
import {useCopilotsStore} from "stores/Copilots";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
preFetch({store, currentRoute}) {
|
preFetch({currentRoute}) {
|
||||||
return useCopilotsStore(store).fetchPublicDetail(currentRoute.params.id, currentRoute.params.username);
|
return useCopilotsStore().fetchPublicDetail(currentRoute.params.id, currentRoute.params.username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import FlightsList from "components/flights/FlightsList.vue";
|
import FlightsList from "components/flights/FlightsList.vue";
|
||||||
import {useAppStore} from "stores/App";
|
import {useAppStore} from "stores/App";
|
||||||
import BasicListSkeleton from "components/basicSkeletons/BasicListSkeleton.vue";
|
import BasicListSkeleton from "components/basicSkeletons/BasicListSkeleton.vue";
|
||||||
import {storeToRefs} from "pinia";
|
import {storeToRefs} from "pinia";
|
||||||
import {onMounted} from "vue";
|
import {onMounted, onServerPrefetch} from "vue";
|
||||||
import {useFlightsStore} from "stores/Flights";
|
import {useFlightsStore} from "stores/Flights";
|
||||||
import {usePhotosStore} from "stores/Photos";
|
import {usePhotosStore} from "stores/Photos";
|
||||||
import FlightsListSkeleton from "components/flights/skeletons/FlightsListSkeleton.vue";
|
import FlightsListSkeleton from "components/flights/skeletons/FlightsListSkeleton.vue";
|
||||||
@@ -21,13 +20,21 @@ import ContentCard from "components/ContentCard.vue";
|
|||||||
import PhotoGallery from "components/photos/PhotoGallery.vue";
|
import PhotoGallery from "components/photos/PhotoGallery.vue";
|
||||||
import {useMeta} from "quasar";
|
import {useMeta} from "quasar";
|
||||||
import {metaData} from "src/composables/meta";
|
import {metaData} from "src/composables/meta";
|
||||||
|
// import {useCopilotsStore} from "stores/Copilots";
|
||||||
|
// import {useRoute} from "vue-router";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
pilot: {
|
pilot: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
|
// const currentRoute = useRoute();
|
||||||
|
//
|
||||||
|
// onServerPrefetch(() => {
|
||||||
|
//
|
||||||
|
// })
|
||||||
|
|
||||||
const {copilot, isQueryRunning} = storeToRefs(useCopilotsStore());
|
const {copilot, isQueryRunning} = storeToRefs(useCopilotsStore());
|
||||||
const {flights, isQueryRunning: areFlightsLoading} = storeToRefs(useFlightsStore());
|
const {flights, isQueryRunning: areFlightsLoading} = storeToRefs(useFlightsStore());
|
||||||
@@ -47,8 +54,10 @@ useMeta(() => metaData({
|
|||||||
image: copilot.value.titleImage?.url
|
image: copilot.value.titleImage?.url
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
useFlightsStore().fetchPublic({copilotId: copilot.value.id});
|
useFlightsStore().fetchPublic({copilotId: copilot.value.id});
|
||||||
usePhotosStore().fetchPublic({copilotId: copilot.value.id})
|
usePhotosStore().fetchPublic({copilotId: copilot.value.id})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -18,12 +18,15 @@ export const useCopilotsStore = defineStore('Copilots', () => {
|
|||||||
}).then(item => copilot.value = item);
|
}).then(item => copilot.value = item);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchPublicDetail = (id, username) => {
|
const fetchPublicDetail = (copilotId, username) => {
|
||||||
return query({
|
return query({
|
||||||
isQueryRunning,
|
isQueryRunning,
|
||||||
query: COPILOT_PUBLIC_DETAIL,
|
query: COPILOT_PUBLIC_DETAIL,
|
||||||
variables: {id, pilotUsername: username},
|
variables: {id: copilotId, pilotUsername: username},
|
||||||
}).then(item => copilot.value = item);
|
}).then(item => {
|
||||||
|
copilot.value = item;
|
||||||
|
return item;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetch = () => {
|
const fetch = () => {
|
||||||
|
|||||||
+14
-18
@@ -4,6 +4,7 @@ import {EDIT_USER} from "src/graphql/mutations/user";
|
|||||||
import {LOGGED_USER_DETAIL, USER_DETAIL} from "src/graphql/queries/user";
|
import {LOGGED_USER_DETAIL, USER_DETAIL} from "src/graphql/queries/user";
|
||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import {mutate, query} from "stores/helpers";
|
import {mutate, query} from "stores/helpers";
|
||||||
|
import {cookies} from "boot/cookies";
|
||||||
|
|
||||||
export const useUserStore = defineStore('LoggedUser', () => {
|
export const useUserStore = defineStore('LoggedUser', () => {
|
||||||
const user = ref(null);
|
const user = ref(null);
|
||||||
@@ -55,40 +56,35 @@ export const useUserStore = defineStore('LoggedUser', () => {
|
|||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
return api.post("/logout").then(response => {
|
return api.post("/logout").then(response => {
|
||||||
localStorage.removeItem("accessToken");
|
unsetTokens();
|
||||||
localStorage.removeItem("accessTokenValidity");
|
|
||||||
user.value = null;
|
user.value = null;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const unsetTokens = () => {
|
||||||
|
cookies.remove("accessToken")
|
||||||
|
};
|
||||||
|
|
||||||
const setTokens = ({access_token, access_token_validity}) => {
|
const setTokens = ({access_token, access_token_validity}) => {
|
||||||
const now = new Date().getTime() / 1000;
|
const now = new Date().getTime() / 1000;
|
||||||
localStorage.setItem("accessToken", access_token);
|
// TODO: asi nefunguje expirace
|
||||||
localStorage.setItem("accessTokenValidity", now + access_token_validity);
|
cookies.set("accessToken", access_token, {expires: now + access_token_validity})
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAccessToken = () => {
|
const getAccessToken = () => {
|
||||||
// TODO: https://dev.to/quasar/quasar-ssr-using-cookies-with-other-libs-services-4nkl
|
return cookies.get("accessToken");
|
||||||
if (typeof localStorage === 'undefined') return null;
|
|
||||||
|
|
||||||
const tokenValidity = localStorage.getItem("accessTokenValidity");
|
|
||||||
const now = new Date().getTime() / 1000;
|
|
||||||
|
|
||||||
if (tokenValidity < now) {
|
|
||||||
localStorage.removeItem("accessToken");
|
|
||||||
localStorage.removeItem("accessTokenValidity");
|
|
||||||
}
|
|
||||||
|
|
||||||
return localStorage.getItem(`accessToken`);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasAccessToken = () => !!localStorage.getItem("accessToken");
|
const hasAccessToken = () => !!getAccessToken();
|
||||||
|
|
||||||
const refreshAccessToken = async () => api.post("/refresh")
|
const refreshAccessToken = async () => api.post("/refresh")
|
||||||
.then(({data}) => {
|
.then(({data}) => {
|
||||||
setTokens(data);
|
setTokens(data);
|
||||||
|
console.log("token refreshed");
|
||||||
return data.access_token;
|
return data.access_token;
|
||||||
});
|
}).catch((e) => {
|
||||||
|
console.log("cannot refresh token", e);
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isQueryRunning, isMutationRunning, user, publicUser, fetchLoggedUserDetail, fetchPublicUserDetail, update,
|
isQueryRunning, isMutationRunning, user, publicUser, fetchLoggedUserDetail, fetchPublicUserDetail, update,
|
||||||
|
|||||||
Reference in New Issue
Block a user