Skip to content

Commit

Permalink
fix: on failed login, isLading is never reset (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
aversini authored Jul 9, 2024
1 parent 22bd7ad commit a8f52e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/code-flow/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const App = ({ timeout }: { timeout: string }) => {
useAuth();
const [apiResponse, setApiResponse] = useState({ data: "" });

console.info({ isAuthenticated, isLoading });

const logger = console;
logger.log("isAuthenticated", isAuthenticated);
logger.log("isLoading", isLoading);
Expand All @@ -32,6 +34,7 @@ export const App = ({ timeout }: { timeout: string }) => {
const response = await login(
process.env.PUBLIC_TEST_USER as string,
"invalid-password",
AUTH_TYPES.CODE,
);
if (!response) {
console.error(`==> [${Date.now()}] : `, "Login failed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ export const AuthProvider = ({
return true;
}
removeStateAndLocalStorage(LOGIN_ERROR);
setAuthState((prev) => ({
...prev,
isLoading: false,
}));
return false;
}
return false;
Expand Down Expand Up @@ -219,6 +223,10 @@ export const AuthProvider = ({
return true;
}
removeStateAndLocalStorage(LOGIN_ERROR);
setAuthState((prev) => ({
...prev,
isLoading: false,
}));
return false;
};

Expand Down

0 comments on commit a8f52e7

Please sign in to comment.