Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32211 ECL Watch v9 fix password expiry check #18859

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
jeclrsg marked this conversation as resolved.
Show resolved Hide resolved
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
Loading