Skip to content

Commit

Permalink
Adds externalLoginUrl to SessionExpiredModal
Browse files Browse the repository at this point in the history
This allows a commons to direct the user to any login page, including a
data-portal login page, when a user's session expires.
  • Loading branch information
k-burt-uch committed Jan 17, 2025
1 parent 8b16ab0 commit f4ac9e9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ yarn-error.log*
packages/sampleCommons/config/canine
packages/sampleCommons/config/midrc
packages/sampleCommons/config/heal
packages/sampleCommons/config/bdc
packages/sampleCommons/.env.development
/packages/frontend/.rollup.cache/
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const getModal = (
break;
}
case Modals.SessionExpireModal: {
res = <SessionExpiredModal openModal={true} />;
res = <SessionExpiredModal openModal={true} config={config.sessionExpiredModal}/>;
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ import { useCallback } from 'react';
import { useRouter } from 'next/router';
import { Text } from '@mantine/core';
import { BaseModal } from './BaseModal';
import { SessionExpiredModalConfig } from "./types";

export const SessionExpiredModal = ({
openModal,
config
}: {
openModal: boolean;
config: SessionExpiredModalConfig;
}): JSX.Element => {

const router = useRouter();
const onLogout = useCallback(() => {
router.push('/Login');
router.push(config.externalLoginUrl || '/Login');
}, [router]);

return (
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/components/Modals/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export interface FirstTimeModalConfig extends BaseModalConfig{
expireDays?: number;
}

export interface SessionExpiredModalConfig extends BaseModalConfig{
externalLoginUrl?: string;
}

export interface ModalsConfig {
systemUseModal?: FirstTimeModalConfig;
sessionExpiredModal?: SessionExpiredModalConfig;
}
4 changes: 2 additions & 2 deletions packages/sampleCommons/.env.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GEN3_COMMONS_NAME=gen3
NEXT_PUBLIC_GEN3_API=https://localhost:3010
GEN3_COMMONS_NAME=bdc
NEXT_PUBLIC_GEN3_API=https://staging.gen3.biodatacatalyst.nhlbi.nih.gov/

## For more fine grain control over the API uncomment the relevant lines
#NEXT_PUBLIC_GEN3_SUBMISSION_API=https://localhost:3010/api/v0/submission
Expand Down

0 comments on commit f4ac9e9

Please sign in to comment.