Skip to content

Commit

Permalink
Merge pull request #952 from akto-api-security/bugfix/login_page_fix
Browse files Browse the repository at this point in the history
login page redirect fix
  • Loading branch information
notshivansh authored Mar 20, 2024
2 parents 9546788 + 67bddc8 commit 8dafef8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export default function Header() {
[],
);

const handleLogOut = async () => {
storeAccessToken(null)
resetAll();
const handleLogOut = async () => {
api.logout().then(res => {
resetAll();
storeAccessToken(null)
if(res.logoutUrl){
window.location.href = res.logoutUrl
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/web/polaris_web/web/src/apps/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const router = createBrowserRouter([
},
{
path: "/",
element: <Navigate to="/login" />,
element: <TokenValidator />,
},
{
path: "/signup",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react'
import { useEffect } from 'react'
import { useNavigate } from 'react-router-dom'
import PersistStore from './PersistStore'

function TokenValidator() {

let navigate = useNavigate()
const accessToken = PersistStore(state => state.accessToken)
useEffect(() => {
console.log(accessToken)
if (accessToken === null || accessToken === '') {
navigate('/login')
} else {
navigate('/dashboard/observe/inventory')
}
},[accessToken])
return (
<></>
)
}

export default TokenValidator

0 comments on commit 8dafef8

Please sign in to comment.