@digitaldefiance/express-suite-react-components 4.27.3 → 4.27.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "4.27.
|
|
3
|
+
"version": "4.27.4",
|
|
4
4
|
"homepage": "https://github.com/Digital-Defiance/react-components",
|
|
5
5
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
6
6
|
"repository": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserSettingsFormWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/UserSettingsFormWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA6C,MAAM,OAAO,CAAC;AACtE,OAAO,EAA4C,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGjH,OAAO,EAA2B,UAAU,EAAsB,MAAM,iCAAiC,CAAC;AAG1G,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,WAAW,4BAA4B;IAC3C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,eAAe,GAAG,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC;CACnG;AAED,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,
|
|
1
|
+
{"version":3,"file":"UserSettingsFormWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/UserSettingsFormWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA6C,MAAM,OAAO,CAAC;AACtE,OAAO,EAA4C,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGjH,OAAO,EAA2B,UAAU,EAAsB,MAAM,iCAAiC,CAAC;AAG1G,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,WAAW,4BAA4B;IAC3C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,eAAe,GAAG,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC;CACnG;AAED,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CA0GpE,CAAC"}
|
|
@@ -12,7 +12,6 @@ const authenticatedApi_1 = require("../services/authenticatedApi");
|
|
|
12
12
|
const UserSettingsFormWrapper = ({ onSuccess, constants, eciesConfig, emailDomain = '', totpAvailable = false, componentProps = {}, }) => {
|
|
13
13
|
const { settings, updateSettings } = (0, hooks_1.useUserSettingsPublic)();
|
|
14
14
|
const { languages, baseUrl } = (0, contexts_1.useSuiteConfig)();
|
|
15
|
-
const { isAuthenticated } = (0, contexts_1.useAuth)();
|
|
16
15
|
// Fetch totpEnabled from the settings API
|
|
17
16
|
const [totpEnabled, setTotpEnabled] = (0, react_1.useState)(undefined);
|
|
18
17
|
const authenticatedApi = (0, react_1.useMemo)(() => (0, authenticatedApi_1.createAuthenticatedApiClient)(baseUrl), [baseUrl]);
|
|
@@ -21,9 +20,15 @@ const UserSettingsFormWrapper = ({ onSuccess, constants, eciesConfig, emailDomai
|
|
|
21
20
|
return null;
|
|
22
21
|
return (0, authService_1.createAuthService)(constants, baseUrl, eciesConfig, emailDomain);
|
|
23
22
|
}, [constants, eciesConfig, baseUrl, emailDomain]);
|
|
24
|
-
// Fetch totpEnabled from GET /user/settings
|
|
23
|
+
// Fetch totpEnabled from GET /user/settings.
|
|
24
|
+
// We gate on totpAvailable (no point fetching if TOTP isn't enabled on this
|
|
25
|
+
// deployment) but NOT on isAuthenticated — isAuthenticated can be false
|
|
26
|
+
// transiently (e.g. verify 403 on page refresh with a stale token) even
|
|
27
|
+
// when the user has a valid session token in localStorage. The
|
|
28
|
+
// authenticatedApi interceptor attaches the token automatically; if the
|
|
29
|
+
// call fails we leave totpEnabled undefined so no TOTP controls are shown.
|
|
25
30
|
(0, react_1.useEffect)(() => {
|
|
26
|
-
if (!
|
|
31
|
+
if (!totpAvailable)
|
|
27
32
|
return;
|
|
28
33
|
authenticatedApi
|
|
29
34
|
.get('/user/settings')
|
|
@@ -33,7 +38,7 @@ const UserSettingsFormWrapper = ({ onSuccess, constants, eciesConfig, emailDomai
|
|
|
33
38
|
.catch(() => {
|
|
34
39
|
// If the endpoint fails, leave totpEnabled undefined (no TOTP controls shown)
|
|
35
40
|
});
|
|
36
|
-
}, [
|
|
41
|
+
}, [totpAvailable, authenticatedApi]);
|
|
37
42
|
const handleSubmit = async (values) => {
|
|
38
43
|
const result = await updateSettings(values);
|
|
39
44
|
if ('success' in result && result.success && onSuccess) {
|