diff --git a/gui/pages/Dashboard/TopBar.js b/gui/pages/Dashboard/TopBar.js index fbd232dc4..d6601ca3e 100644 --- a/gui/pages/Dashboard/TopBar.js +++ b/gui/pages/Dashboard/TopBar.js @@ -21,8 +21,9 @@ export default function TopBar({selectedProject, userName, env}) { return; } getUserClick('Logged Out',{}) - localStorage.removeItem('accessToken'); - Cookies.set('accessToken', '', { expires: new Date(0), domain: '.superagi.com', path: '/' }); + // localStorage.removeItem('accessToken'); + Cookies.set('accessToken', '', { expires: new Date(0),domain: '.superagi.com', path: '/'}); + Cookies.set('Source', 'app.superagi', {domain: '.superagi.com', path: '/'}); refreshUrl(); router.reload(); }; diff --git a/gui/pages/_app.js b/gui/pages/_app.js index 126c9f247..43ab91a8a 100644 --- a/gui/pages/_app.js +++ b/gui/pages/_app.js @@ -135,7 +135,8 @@ export default function App() { const singupCampaign = sessionStorage.getItem('campaign'); if (typeof window !== 'undefined' && access_token) { - localStorage.setItem('accessToken', access_token); + // localStorage.setItem('accessToken', access_token); + Cookies.set('accessToken', access_token, { domain: '.superagi.com', path: '/' }); refreshUrl(); } validateAccessToken() @@ -152,7 +153,6 @@ export default function App() { if(signupSource) { handleSignUpSource(signupSource) } - Cookies.set('accessToken', localStorage.getItem('accessToken'),{ domain: '.superagi.com', path: '/' }); fetchOrganisation(response.data.id); }) .catch((error) => { diff --git a/gui/pages/api/apiConfig.js b/gui/pages/api/apiConfig.js index 14da159c4..0c58bebb8 100644 --- a/gui/pages/api/apiConfig.js +++ b/gui/pages/api/apiConfig.js @@ -1,4 +1,5 @@ import axios from 'axios'; +import Cookies from "js-cookie"; const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID; const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8001'; @@ -37,7 +38,8 @@ const api = axios.create({ api.interceptors.request.use(config => { if (typeof window !== 'undefined') { - const accessToken = localStorage.getItem("accessToken"); + // const accessToken = localStorage.getItem("accessToken"); + const accessToken = Cookies.get("accessToken"); if (accessToken) { config.headers['Authorization'] = `Bearer ${accessToken}`; } diff --git a/gui/utils/utils.js b/gui/utils/utils.js index c601e76d3..8d190968f 100644 --- a/gui/utils/utils.js +++ b/gui/utils/utils.js @@ -5,6 +5,7 @@ import {EventBus} from "@/utils/eventBus"; import JSZip from "jszip"; import moment from 'moment'; import mixpanel from 'mixpanel-browser' +import Cookies from "js-cookie"; const toolkitData = { 'Jira Toolkit': '/images/jira_icon.svg', @@ -114,7 +115,8 @@ export const formatBytes = (bytes, decimals = 2) => { }; export const downloadFile = (fileId, fileName = null) => { - const authToken = localStorage.getItem('accessToken'); + // const authToken = localStorage.getItem('accessToken'); + const authToken = Cookies.get("accessToken"); const url = `${baseUrl()}/resources/get/${fileId}`; const env = localStorage.getItem('applicationEnvironment');