diff --git a/src/pages/LoginPage.vue b/src/pages/LoginPage.vue index 8308973..d99fe21 100644 --- a/src/pages/LoginPage.vue +++ b/src/pages/LoginPage.vue @@ -36,6 +36,13 @@ :icon="arrowForwardOutline" > + + Testes sem login + + @@ -136,6 +143,14 @@ export default { } } }, + fakeLogin() { + this.wpStore.login( + 'https://rcteste.tainacan.org', + '', + '' + ); + this.$router.push("/home"); + } }, }; diff --git a/src/store/storeTainacan.ts b/src/store/storeTainacan.ts index b35c79c..72fd712 100644 --- a/src/store/storeTainacan.ts +++ b/src/store/storeTainacan.ts @@ -26,7 +26,7 @@ const useTainacanStore = defineStore("tainacan", { const wpStore = useWpStore(); let endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/collections?`; - const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); + const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null; if (params && params.perPage) endpoint += '&perpage=' + params.perPage; @@ -34,11 +34,11 @@ const useTainacanStore = defineStore("tainacan", { if (params && params.orderBy) endpoint += '&orderby=' + params.orderBy; - const response = await axios.get(endpoint, { + const response = await axios.get(endpoint, authorization ? { headers: { authorization: authorization } - }); + } : {}); this.collections = response.data; this.totalCollections = response.headers['x-wp-total']; @@ -57,13 +57,13 @@ const useTainacanStore = defineStore("tainacan", { const wpStore = useWpStore(); const endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/collections?perpage=4&orderby=modified`; - const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); + const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null; - const response = await axios.get(endpoint, { + const response = await axios.get(endpoint, authorization ? { headers: { authorization: authorization } - }); + } : {}); this.homeCollections = response.data; this.totalHomeCollections = response.headers['x-wp-total']; @@ -82,7 +82,7 @@ const useTainacanStore = defineStore("tainacan", { const wpStore = useWpStore(); let endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/collection/${collectionId}/items?fetch_only=id,title,thumbnail`; - const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); + const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null; if (params && params.perPage) endpoint += '&perpage=' + params.perPage; @@ -104,11 +104,11 @@ const useTainacanStore = defineStore("tainacan", { endpoint += '&paged=' + this.nextItemsByCollectionPage; - const response = await axios.get(endpoint, { + const response = await axios.get(endpoint, authorization ? { headers: { authorization: authorization } - }); + } : {}); this.collectionItems.push(...response.data.items); this.totalCollectionItems = response.headers['x-wp-total']; @@ -132,13 +132,13 @@ const useTainacanStore = defineStore("tainacan", { const wpStore = useWpStore(); const endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/items?fetch_only=id,title,thumbnail&perpage=12&orderby=modified`; - const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); + const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null; - const response = await axios.get(endpoint, { + const response = await axios.get(endpoint, authorization ? { headers: { authorization: authorization } - }); + } : {}); this.homeItems = response.data.items; this.totalHomeItems = response.headers['x-wp-total']; @@ -156,7 +156,7 @@ const useTainacanStore = defineStore("tainacan", { const wpStore = useWpStore(); let endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/items?fetch_only=id,title,thumbnail`; - const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); + const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null; if (params && params.perPage) endpoint += '&perpage=' + params.perPage; @@ -174,11 +174,11 @@ const useTainacanStore = defineStore("tainacan", { endpoint += '&paged=' + this.nextItemsPage; - const response = await axios.get(endpoint, { + const response = await axios.get(endpoint, authorization ? { headers: { authorization: authorization } - }); + } : {}); this.items.push(...response.data.items); this.totalItems = response.headers['x-wp-total'];