Skip to content

Commit

Permalink
feat: ✨ add logout sso
Browse files Browse the repository at this point in the history
  • Loading branch information
newarifrh committed Sep 30, 2024
1 parent 9e13675 commit 4a239fa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VITE_APP_NAME=Serambi
VITE_BUILD_HASH=local
VITE_BUILD_HASH=local
VITE_HAS_LOGIN_SSO=true
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_API_BASE_URL=https://api-serambi.bpsbontang.com
VITE_HAS_LOGIN_SSO=false
VITE_HAS_LOGIN_SSO=true
Binary file modified bun.lockb
Binary file not shown.
5 changes: 3 additions & 2 deletions src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import React, {
useEffect,
useCallback,
} from "react";
import { login as loginApi, logout as logoutApi } from "@/api/Auth";
import { login as loginApi } from "@/api/Auth";
import { User } from "@/types/User";
import { me } from "@/api/User";
import Cookies from "js-cookie";
import { API_BASE_URL } from "@/configs/Constant";

interface AuthContextType {
isAuthenticated: boolean;
Expand Down Expand Up @@ -105,10 +106,10 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
}, []);

const logout = useCallback(async () => {
await logoutApi();
setIsAuthenticated(false);
setUser(null);
localStorage.removeItem("isAuthenticated");
window.location.href = `${API_BASE_URL}/v1/auth/logout`;
}, []);

return (
Expand Down

0 comments on commit 4a239fa

Please sign in to comment.