Client: Confirm: get data from store

This commit is contained in:
Viktor Fomin 2022-12-01 18:27:46 +03:00
parent 9951111cd3
commit c4d5f3b5ff
2 changed files with 24 additions and 9 deletions

View File

@ -253,7 +253,7 @@ const Confirm = (props) => {
};
useEffect(() => {
const { isAuthenticated, logout, linkData, setProviders } = props;
const { isAuthenticated, logout, linkData, capabilities } = props;
if (isAuthenticated) {
const path = window.location;
@ -268,12 +268,8 @@ const Confirm = (props) => {
window.authCallback = authCallback;
const providers = await getAuthProviders();
const ssoData = await getCapabilities();
setProviders(providers);
setSsoLabel(ssoData.ssoLabel);
setSsoUrl(ssoData.ssoUrl);
setSsoLabel(capabilities?.ssoLabel);
setSsoUrl(capabilities?.ssoUrl);
focusInput();
};
@ -790,9 +786,9 @@ export default inject(({ auth }) => {
logout,
isAuthenticated,
settingsStore,
setProviders,
providers,
thirdPartyLogin,
capabilities,
} = auth;
const {
passwordSettings,
@ -814,8 +810,8 @@ export default inject(({ auth }) => {
getSettings,
getPortalPasswordSettings,
thirdPartyLogin,
setProviders,
providers,
capabilities,
};
})(
withRouter(

View File

@ -16,6 +16,8 @@ export default function withLoader(WrappedComponent) {
getSettings,
getPortalPasswordSettings,
history,
getAuthProviders,
getCapabilities,
} = props;
const [inLoad, setInLoad] = useState(false);
@ -43,6 +45,20 @@ export default function withLoader(WrappedComponent) {
}
}, [passwordSettings]);
useEffect(() => {
if (type === "LinkInvite") {
axios.all([getAuthProviders(), getCapabilities()]).catch((error) => {
console.error(error);
history.push(
combineUrl(
AppServerConfig.proxyURL,
`/login/error?message=${error}`
)
);
});
}
}, []);
const isLoaded =
type === "TfaActivation" || type === "TfaAuth"
? props.isLoaded
@ -87,6 +103,7 @@ export default function withLoader(WrappedComponent) {
getSettings,
getPortalPasswordSettings,
} = auth.settingsStore;
const { getAuthProviders, getCapabilities } = auth;
return {
isLoaded,
@ -94,6 +111,8 @@ export default function withLoader(WrappedComponent) {
getSettings,
passwordSettings,
getPortalPasswordSettings,
getAuthProviders,
getCapabilities,
};
})(observer(withLoader));
}