@zesty-io/material 0.12.2 → 0.12.3
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/es/SSOButtonGroup/index.js +1 -1
- package/es/theme/index.js +8 -0
- package/es/utils/useSSO.d.ts +6 -1
- package/es/utils/useSSO.js +6 -2
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ const SSOButtonGroup = ({ children, sx, authServiceUrl, onSuccess, onError, }) =
|
|
|
9
9
|
onSuccess(message);
|
|
10
10
|
}
|
|
11
11
|
else if (ssoError && onError) {
|
|
12
|
-
onError(ssoError);
|
|
12
|
+
onError(ssoError.message);
|
|
13
13
|
}
|
|
14
14
|
}, [isAuthenticated, ssoError]);
|
|
15
15
|
return (_jsx(Box, { display: "flex", flexDirection: "column", gap: 2, sx: sx, children: React.Children.map(children, (child) => {
|
package/es/theme/index.js
CHANGED
package/es/utils/useSSO.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export declare type SSOService = "github" | "google" | "azure";
|
|
2
|
-
|
|
2
|
+
interface Error {
|
|
3
|
+
message: string;
|
|
4
|
+
status: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const useSSO: (authServiceUrl: string) => readonly [(service: SSOService) => void, boolean, Error | null, {}];
|
|
7
|
+
export {};
|
package/es/utils/useSSO.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
+
;
|
|
2
3
|
let tabWindow = null;
|
|
3
4
|
export const useSSO = (authServiceUrl) => {
|
|
4
5
|
const [message, setMessage] = useState({});
|
|
5
6
|
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
6
|
-
const [error, setError] = useState(
|
|
7
|
+
const [error, setError] = useState(null);
|
|
7
8
|
const receiveMessage = (event) => {
|
|
8
9
|
if (event.origin === authServiceUrl && event.data.source === "zesty") {
|
|
9
10
|
setMessage(event.data);
|
|
@@ -11,7 +12,10 @@ export const useSSO = (authServiceUrl) => {
|
|
|
11
12
|
setIsAuthenticated(true);
|
|
12
13
|
}
|
|
13
14
|
else {
|
|
14
|
-
setError(
|
|
15
|
+
setError({
|
|
16
|
+
message: event.data.error_message,
|
|
17
|
+
status: event.data.status,
|
|
18
|
+
});
|
|
15
19
|
}
|
|
16
20
|
if (tabWindow) {
|
|
17
21
|
tabWindow.close();
|