Skip to content

Commit

Permalink
O3-1444: Expired login session keeps the location page stuck (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsereko authored Jan 4, 2023
1 parent 3ab24c7 commit 9591164
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/apps/esm-login-app/src/login/login.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import {
} from "@carbon/react";
import { ArrowLeft, ArrowRight } from "@carbon/react/icons";
import { useTranslation } from "react-i18next";
import { useConfig, interpolateUrl, useSession } from "@openmrs/esm-framework";
import {
useConfig,
interpolateUrl,
useSession,
refetchCurrentUser,
clearCurrentUser,
getSessionStore,
} from "@openmrs/esm-framework";
import { performLogin } from "./login.resource";
import styles from "./login.scss";

Expand Down Expand Up @@ -44,7 +51,14 @@ const Login: React.FC<LoginProps> = ({ isLoginEnabled }) => {

useEffect(() => {
if (user) {
navigate("/login/location", { state: location.state });
clearCurrentUser();
refetchCurrentUser().then(() => {
const authenticated =
getSessionStore().getState().session.authenticated;
if (authenticated) {
navigate("/login/location", { state: location.state });
}
});
} else if (!username && location.pathname === "/login/confirm") {
navigate("/login", { state: location.state });
}
Expand Down

0 comments on commit 9591164

Please sign in to comment.