Skip to content

Commit

Permalink
logout bug complete
Browse files Browse the repository at this point in the history
  • Loading branch information
namansleeps committed Oct 10, 2023
1 parent c02fe30 commit 28048d5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions gui/pages/Dashboard/TopBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)});
Cookies.set('Source', 'app.superagi', {domain: '.superagi.com', path: '/'});
refreshUrl();
router.reload();
};
Expand Down
4 changes: 2 additions & 2 deletions gui/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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) => {
Expand Down
4 changes: 3 additions & 1 deletion gui/pages/api/apiConfig.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}`;
}
Expand Down
4 changes: 3 additions & 1 deletion gui/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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');

Expand Down

0 comments on commit 28048d5

Please sign in to comment.