Skip to content

Commit

Permalink
HPCC-32211 ECL Watch v9 fix password expiry check
Browse files Browse the repository at this point in the history
change ECL Watch v9's password expiry check to work the same as v5,
relying only on the value of passwordDaysRemaining from ESP

Signed-off-by: Jeremy Clements <[email protected]>
  • Loading branch information
jeclrsg committed Jul 10, 2024
1 parent f11a6d1 commit f2fd504
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
37 changes: 27 additions & 10 deletions esp/src/src-react/components/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import nlsHPCC from "src/nlsHPCC";
import * as Utility from "src/Utility";

import { useBanner } from "../hooks/banner";
import { useConfirm } from "../hooks/confirm";
import { replaceUrl } from "../util/history";
import { useECLWatchLogger } from "../hooks/logging";
import { useBuildInfo, useModernMode } from "../hooks/platform";
import { useBuildInfo, useModernMode, useCheckFeatures } from "../hooks/platform";
import { useGlobalStore } from "../hooks/store";
import { useMyAccount, useUserSession } from "../hooks/user";
import { replaceUrl } from "../util/history";
import { useCheckFeatures } from "../hooks/platform";

import { TitlebarConfig } from "./forms/TitlebarConfig";
import { switchTechPreview } from "./controls/ComingSoon";
Expand Down Expand Up @@ -65,6 +65,15 @@ export const DevTitle: React.FunctionComponent<DevTitleProps> = ({
const [showBannerConfig, setShowBannerConfig] = React.useState(false);
const [BannerMessageBar, BannerConfig] = useBanner({ showForm: showBannerConfig, setShowForm: setShowBannerConfig });

const [PasswordExpiredConfirm, setPasswordExpiredConfirm] = useConfirm({
title: nlsHPCC.PasswordExpiration,
message: nlsHPCC.PasswordExpired,
cancelLabel: null,
onSubmit: React.useCallback(() => {
setShowMyAccount(true);
}, [])
});

const titlebarColorSet = React.useMemo(() => {
return titlebarColor && titlebarColor !== theme.palette.themeLight;
}, [theme.palette, titlebarColor]);
Expand Down Expand Up @@ -236,13 +245,20 @@ export const DevTitle: React.FunctionComponent<DevTitleProps> = ({
if (!cookie("PasswordExpiredCheck")) {
// cookie expires option expects whole number of days, use a decimal < 1 for hours
cookie("PasswordExpiredCheck", "true", { expires: 0.5, path: "/" });
if (currentUser.passwordIsExpired) {
alert(nlsHPCC.PasswordExpired);
setShowMyAccount(true);
} else if (currentUser.passwordDaysRemaining && currentUser.passwordDaysRemaining <= currentUser.passwordExpirationWarningDays) {
if (confirm(nlsHPCC.PasswordExpirePrefix + currentUser.passwordDaysRemaining + nlsHPCC.PasswordExpirePostfix)) {
setShowMyAccount(true);
}
switch (currentUser.passwordDaysRemaining) {
case -1:
setPasswordExpiredConfirm(true);
break;
case -2:
case null:
break;
default:
if (currentUser?.passwordDaysRemaining <= currentUser?.passwordExpirationWarningDays) {
if (confirm(nlsHPCC.PasswordExpirePrefix + currentUser.passwordDaysRemaining + nlsHPCC.PasswordExpirePostfix)) {
setShowMyAccount(true);
}
}
break;
}
}
}, [currentUser]);

Check warning on line 264 in esp/src/src-react/components/Title.tsx

View workflow job for this annotation

GitHub Actions / Check eclwatch and npm (20)

React Hook React.useEffect has a missing dependency: 'setPasswordExpiredConfirm'. Either include it or remove the dependency array

Check warning on line 264 in esp/src/src-react/components/Title.tsx

View workflow job for this annotation

GitHub Actions / Check eclwatch and npm (18)

React Hook React.useEffect has a missing dependency: 'setPasswordExpiredConfirm'. Either include it or remove the dependency array

Check warning on line 264 in esp/src/src-react/components/Title.tsx

View workflow job for this annotation

GitHub Actions / Check eclwatch and npm (16)

React Hook React.useEffect has a missing dependency: 'setPasswordExpiredConfirm'. Either include it or remove the dependency array
Expand Down Expand Up @@ -296,6 +312,7 @@ export const DevTitle: React.FunctionComponent<DevTitleProps> = ({
<MyAccount currentUser={currentUser} show={showMyAccount} onClose={() => setShowMyAccount(false)}></MyAccount>
<TitlebarConfig toolbarThemeDefaults={toolbarThemeDefaults} showForm={showTitlebarConfig} setShowForm={setShowTitlebarConfig} />
<BannerConfig />
<PasswordExpiredConfirm />
</div>;
};

2 changes: 1 addition & 1 deletion esp/src/src-react/hooks/confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function useConfirm({ title, message, items = [], onSubmit, submitLabel =
setShow(false);
}}
/>
<DefaultButton text={cancelLabel} onClick={() => setShow(false)} />
{cancelLabel && <DefaultButton text={cancelLabel} onClick={() => setShow(false)} />}
</DialogFooter>
</Dialog>;
}, [cancelLabel, items, message, onSubmit, show, submitLabel, title]);
Expand Down

0 comments on commit f2fd504

Please sign in to comment.