Skip to content

Commit

Permalink
Merge pull request #18859 from jeclrsg/hpcc-32211-eclwatch-v9-passwor…
Browse files Browse the repository at this point in the history
…d-expiry-check

HPCC-32211 ECL Watch v9 fix password expiry check
  • Loading branch information
GordonSmith authored Jul 11, 2024
2 parents 122e47c + 32f69e4 commit e867d43
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
4 changes: 2 additions & 2 deletions esp/src/eclwatch/HPCCPlatformWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ define([
switch (response.MyAccountResponse.passwordDaysRemaining) {
case null:
break;
case -1:
case -1: // password has expired
alert(context.i18n.PasswordExpired);
context._onUserID();
break;
case -2:
case -2: // password never expires
break;
default:
if (response.MyAccountResponse.passwordDaysRemaining && response.MyAccountResponse.passwordDaysRemaining <= response.MyAccountResponse.passwordExpirationWarningDays) {
Expand Down
39 changes: 28 additions & 11 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,16 +245,23 @@ 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: // password has expired
setPasswordExpiredConfirm(true);
break;
case -2: // password never expires
case null:
break;
default:
if (currentUser?.passwordDaysRemaining <= currentUser?.passwordExpirationWarningDays) {
if (confirm(nlsHPCC.PasswordExpirePrefix + currentUser.passwordDaysRemaining + nlsHPCC.PasswordExpirePostfix)) {
setShowMyAccount(true);
}
}
break;
}
}
}, [currentUser]);
}, [currentUser, setPasswordExpiredConfirm]);

return <div style={{ backgroundColor: titlebarColorSet ? titlebarColor : theme.palette.themeLight }}>
<BannerMessageBar />
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 e867d43

Please sign in to comment.