@springmicro/auth 0.7.5 → 0.7.6

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.
Files changed (45) hide show
  1. package/README.md +60 -60
  2. package/package.json +2 -2
  3. package/src/components/forms/AgreementModal.tsx +88 -88
  4. package/src/components/forms/CaptchaController.tsx +94 -94
  5. package/src/components/forms/CaptchaModal.jsx +171 -171
  6. package/src/components/forms/CaptchaWidget.jsx +146 -146
  7. package/src/components/forms/PasswordChecker.ts +88 -88
  8. package/src/components/forms/util/auth-api.ts +198 -198
  9. package/src/components/forms/util/auth-util.tsx +346 -346
  10. package/src/components/forms/util/core.ts +493 -493
  11. package/src/components/forms/util/invitation-api.ts +132 -132
  12. package/src/components/forms/util/provider.tsx +603 -603
  13. package/src/components/provider/AdfsLoginButton.jsx +38 -38
  14. package/src/components/provider/AlipayLoginButton.jsx +38 -38
  15. package/src/components/provider/AppleLoginButton.jsx +38 -38
  16. package/src/components/provider/AzureADB2CLoginButton.jsx +38 -38
  17. package/src/components/provider/AzureADLoginButton.jsx +38 -38
  18. package/src/components/provider/BaiduLoginButton.jsx +38 -38
  19. package/src/components/provider/BilibiliLoginButton.jsx +37 -37
  20. package/src/components/provider/CasdoorLoginButton.jsx +38 -38
  21. package/src/components/provider/DingTalkLoginButton.jsx +37 -37
  22. package/src/components/provider/DouyinLoginButton.jsx +38 -38
  23. package/src/components/provider/FacebookLoginButton.jsx +37 -37
  24. package/src/components/provider/GitHubLoginButton.jsx +37 -37
  25. package/src/components/provider/GitLabLoginButton.jsx +38 -38
  26. package/src/components/provider/GiteeLoginButton.jsx +34 -34
  27. package/src/components/provider/GoogleLoginButton.jsx +68 -68
  28. package/src/components/provider/InfoflowLoginButton.jsx +38 -38
  29. package/src/components/provider/LarkLoginButton.jsx +38 -38
  30. package/src/components/provider/LinkedInLoginButton.jsx +37 -37
  31. package/src/components/provider/LoginButton.jsx +33 -33
  32. package/src/components/provider/OktaLoginButton.jsx +38 -38
  33. package/src/components/provider/Provider.jsx +3 -3
  34. package/src/components/provider/ProviderButton.jsx +327 -327
  35. package/src/components/provider/QqLoginButton.jsx +31 -31
  36. package/src/components/provider/SelfLoginButton.jsx +47 -47
  37. package/src/components/provider/SlackLoginButton.jsx +38 -38
  38. package/src/components/provider/SteamLoginButton.jsx +38 -38
  39. package/src/components/provider/WeComLoginButton.jsx +34 -34
  40. package/src/components/provider/Web3Auth.jsx +365 -365
  41. package/src/components/provider/WechatLoginButton.jsx +37 -37
  42. package/src/components/provider/WeiboLoginButton.jsx +34 -34
  43. package/src/i18n/en/signup.json +48 -48
  44. package/src/i18n/index.ts +17 -17
  45. package/vite.config.ts +33 -33
@@ -1,37 +1,37 @@
1
- // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import { createButton } from "react-social-login-buttons";
16
- import { StaticBaseUrl } from "../forms/util/core";
17
-
18
- function Icon({ width = 24, height = 24, color }) {
19
- return (
20
- <img
21
- src={`${StaticBaseUrl}/buttons/dingtalk.svg`}
22
- alt="Sign in with DingTalk"
23
- />
24
- );
25
- }
26
-
27
- const config = {
28
- text: "Sign in with DingTalk",
29
- icon: Icon,
30
- iconFormat: (name) => `fa fa-${name}`,
31
- style: { background: "#0191e0" },
32
- activeStyle: { background: "rgb(76,143,208)" },
33
- };
34
-
35
- const DingTalkLoginButton = createButton(config);
36
-
37
- export default DingTalkLoginButton;
1
+ // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { createButton } from "react-social-login-buttons";
16
+ import { StaticBaseUrl } from "../forms/util/core";
17
+
18
+ function Icon({ width = 24, height = 24, color }) {
19
+ return (
20
+ <img
21
+ src={`${StaticBaseUrl}/buttons/dingtalk.svg`}
22
+ alt="Sign in with DingTalk"
23
+ />
24
+ );
25
+ }
26
+
27
+ const config = {
28
+ text: "Sign in with DingTalk",
29
+ icon: Icon,
30
+ iconFormat: (name) => `fa fa-${name}`,
31
+ style: { background: "#0191e0" },
32
+ activeStyle: { background: "rgb(76,143,208)" },
33
+ };
34
+
35
+ const DingTalkLoginButton = createButton(config);
36
+
37
+ export default DingTalkLoginButton;
@@ -1,38 +1,38 @@
1
- // Copyright 2022 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import { createButton } from "react-social-login-buttons";
16
- import { StaticBaseUrl } from "../forms/util/core";
17
-
18
- function Icon({ width = 24, height = 24, color }) {
19
- return (
20
- <img
21
- src={`${StaticBaseUrl}/buttons/douyin.svg`}
22
- alt="Sign in with Douyin"
23
- style={{ width: 24, height: 24 }}
24
- />
25
- );
26
- }
27
-
28
- const config = {
29
- text: "Sign in with Douyin",
30
- icon: Icon,
31
- iconFormat: (name) => `fa fa-${name}`,
32
- style: { background: "#ffffff", color: "#000000" },
33
- activeStyle: { background: "#ededee" },
34
- };
35
-
36
- const DouyinLoginButton = createButton(config);
37
-
38
- export default DouyinLoginButton;
1
+ // Copyright 2022 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { createButton } from "react-social-login-buttons";
16
+ import { StaticBaseUrl } from "../forms/util/core";
17
+
18
+ function Icon({ width = 24, height = 24, color }) {
19
+ return (
20
+ <img
21
+ src={`${StaticBaseUrl}/buttons/douyin.svg`}
22
+ alt="Sign in with Douyin"
23
+ style={{ width: 24, height: 24 }}
24
+ />
25
+ );
26
+ }
27
+
28
+ const config = {
29
+ text: "Sign in with Douyin",
30
+ icon: Icon,
31
+ iconFormat: (name) => `fa fa-${name}`,
32
+ style: { background: "#ffffff", color: "#000000" },
33
+ activeStyle: { background: "#ededee" },
34
+ };
35
+
36
+ const DouyinLoginButton = createButton(config);
37
+
38
+ export default DouyinLoginButton;
@@ -1,37 +1,37 @@
1
- // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import { createButton } from "react-social-login-buttons";
16
- import { StaticBaseUrl } from "../forms/util/core";
17
-
18
- function Icon({ width = 24, height = 24, color }) {
19
- return (
20
- <img
21
- src={`${StaticBaseUrl}/buttons/facebook.svg`}
22
- alt="Sign in with Facebook"
23
- />
24
- );
25
- }
26
-
27
- const config = {
28
- text: "Sign in with Facebook",
29
- icon: Icon,
30
- iconFormat: (name) => `fa fa-${name}`,
31
- style: { background: "#3b5998" },
32
- activeStyle: { background: "#2b3f65" },
33
- };
34
-
35
- const FacebookLoginButton = createButton(config);
36
-
37
- export default FacebookLoginButton;
1
+ // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { createButton } from "react-social-login-buttons";
16
+ import { StaticBaseUrl } from "../forms/util/core";
17
+
18
+ function Icon({ width = 24, height = 24, color }) {
19
+ return (
20
+ <img
21
+ src={`${StaticBaseUrl}/buttons/facebook.svg`}
22
+ alt="Sign in with Facebook"
23
+ />
24
+ );
25
+ }
26
+
27
+ const config = {
28
+ text: "Sign in with Facebook",
29
+ icon: Icon,
30
+ iconFormat: (name) => `fa fa-${name}`,
31
+ style: { background: "#3b5998" },
32
+ activeStyle: { background: "#2b3f65" },
33
+ };
34
+
35
+ const FacebookLoginButton = createButton(config);
36
+
37
+ export default FacebookLoginButton;
@@ -1,37 +1,37 @@
1
- // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import { createButton } from "react-social-login-buttons";
16
- import { StaticBaseUrl } from "../forms/util/core";
17
-
18
- function Icon({ width = 24, height = 24, color }) {
19
- return (
20
- <img
21
- src={`${StaticBaseUrl}/buttons/github.svg`}
22
- alt="Sign in with GitHub"
23
- />
24
- );
25
- }
26
-
27
- const config = {
28
- text: "Sign in with GitHub",
29
- icon: Icon,
30
- iconFormat: (name) => `fa fa-${name}`,
31
- style: { background: "#333333" },
32
- activeStyle: { background: "#393934" },
33
- };
34
-
35
- const GitHubLoginButton = createButton(config);
36
-
37
- export default GitHubLoginButton;
1
+ // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { createButton } from "react-social-login-buttons";
16
+ import { StaticBaseUrl } from "../forms/util/core";
17
+
18
+ function Icon({ width = 24, height = 24, color }) {
19
+ return (
20
+ <img
21
+ src={`${StaticBaseUrl}/buttons/github.svg`}
22
+ alt="Sign in with GitHub"
23
+ />
24
+ );
25
+ }
26
+
27
+ const config = {
28
+ text: "Sign in with GitHub",
29
+ icon: Icon,
30
+ iconFormat: (name) => `fa fa-${name}`,
31
+ style: { background: "#333333" },
32
+ activeStyle: { background: "#393934" },
33
+ };
34
+
35
+ const GitHubLoginButton = createButton(config);
36
+
37
+ export default GitHubLoginButton;
@@ -1,38 +1,38 @@
1
- // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import { createButton } from "react-social-login-buttons";
16
- import { StaticBaseUrl } from "../forms/util/core";
17
-
18
- function Icon({ width = 24, height = 24, color }) {
19
- return (
20
- <img
21
- src={`${StaticBaseUrl}/buttons/gitlab.svg`}
22
- alt="Sign in with GitLab"
23
- style={{ width: 24, height: 24 }}
24
- />
25
- );
26
- }
27
-
28
- const config = {
29
- text: "Sign in with GitLab",
30
- icon: Icon,
31
- iconFormat: (name) => `fa fa-${name}`,
32
- style: { background: "rgb(255,255,255)", color: "#000000" },
33
- activeStyle: { background: "rgb(100,150,250)" },
34
- };
35
-
36
- const GitLabLoginButton = createButton(config);
37
-
38
- export default GitLabLoginButton;
1
+ // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { createButton } from "react-social-login-buttons";
16
+ import { StaticBaseUrl } from "../forms/util/core";
17
+
18
+ function Icon({ width = 24, height = 24, color }) {
19
+ return (
20
+ <img
21
+ src={`${StaticBaseUrl}/buttons/gitlab.svg`}
22
+ alt="Sign in with GitLab"
23
+ style={{ width: 24, height: 24 }}
24
+ />
25
+ );
26
+ }
27
+
28
+ const config = {
29
+ text: "Sign in with GitLab",
30
+ icon: Icon,
31
+ iconFormat: (name) => `fa fa-${name}`,
32
+ style: { background: "rgb(255,255,255)", color: "#000000" },
33
+ activeStyle: { background: "rgb(100,150,250)" },
34
+ };
35
+
36
+ const GitLabLoginButton = createButton(config);
37
+
38
+ export default GitLabLoginButton;
@@ -1,34 +1,34 @@
1
- // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import { createButton } from "react-social-login-buttons";
16
- import { StaticBaseUrl } from "../forms/util/core";
17
-
18
- function Icon({ width = 24, height = 24, color }) {
19
- return (
20
- <img src={`${StaticBaseUrl}/buttons/gitee.svg`} alt="Sign in with Gitee" />
21
- );
22
- }
23
-
24
- const config = {
25
- text: "Sign in with Gitee",
26
- icon: Icon,
27
- iconFormat: (name) => `fa fa-${name}`,
28
- style: { background: "rgb(199,29,35)" },
29
- activeStyle: { background: "rgb(147,22,26)" },
30
- };
31
-
32
- const GiteeLoginButton = createButton(config);
33
-
34
- export default GiteeLoginButton;
1
+ // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { createButton } from "react-social-login-buttons";
16
+ import { StaticBaseUrl } from "../forms/util/core";
17
+
18
+ function Icon({ width = 24, height = 24, color }) {
19
+ return (
20
+ <img src={`${StaticBaseUrl}/buttons/gitee.svg`} alt="Sign in with Gitee" />
21
+ );
22
+ }
23
+
24
+ const config = {
25
+ text: "Sign in with Gitee",
26
+ icon: Icon,
27
+ iconFormat: (name) => `fa fa-${name}`,
28
+ style: { background: "rgb(199,29,35)" },
29
+ activeStyle: { background: "rgb(147,22,26)" },
30
+ };
31
+
32
+ const GiteeLoginButton = createButton(config);
33
+
34
+ export default GiteeLoginButton;
@@ -1,68 +1,68 @@
1
- // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import { createButton } from "react-social-login-buttons";
16
- import { StaticBaseUrl } from "../forms/util/core";
17
- import { useGoogleOneTapLogin } from "react-google-one-tap-login";
18
- import * as Setting from "../forms/util/core";
19
- import * as Provider from "./Provider";
20
-
21
- function Icon({ width = 24, height = 24, color }) {
22
- return (
23
- <img
24
- src={`${StaticBaseUrl}/buttons/google.svg`}
25
- alt="Sign in with Google"
26
- />
27
- );
28
- }
29
-
30
- const config = {
31
- text: "Sign in with Google",
32
- icon: Icon,
33
- iconFormat: (name) => `fa fa-${name}`,
34
- style: { background: "#ffffff", color: "#000000" },
35
- activeStyle: { background: "#eff0ee" },
36
- };
37
-
38
- const GoogleLoginButton = createButton(config);
39
-
40
- export function GoogleOneTapLoginVirtualButton(prop) {
41
- const application = prop.application;
42
- const providerConf = prop.providerConf;
43
- // https://stackoverflow.com/questions/62281579/google-one-tap-sign-in-ui-not-displayed-after-clicking-the-close-button
44
- // document.cookie = "g_state=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT";
45
- useGoogleOneTapLogin({
46
- googleAccountConfigs: {
47
- client_id: providerConf.provider.clientId,
48
- },
49
- onError: (error) => {
50
- Setting.showMessage("error", error);
51
- },
52
- onSuccess: (response) => {
53
- const code = "GoogleIdToken-" + JSON.stringify(response);
54
- const authUrlParams = new URLSearchParams(
55
- Provider.getAuthUrl(application, providerConf.provider, "signup")
56
- );
57
- const state = authUrlParams.get("state");
58
- let redirectUri = authUrlParams.get("redirect_uri");
59
- redirectUri = `${redirectUri}?state=${state}&code=${encodeURIComponent(
60
- code
61
- )}`;
62
- Setting.goToLink(redirectUri);
63
- },
64
- disableCancelOnUnmount: false,
65
- });
66
- }
67
-
68
- export default GoogleLoginButton;
1
+ // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { createButton } from "react-social-login-buttons";
16
+ import { StaticBaseUrl } from "../forms/util/core";
17
+ import { useGoogleOneTapLogin } from "react-google-one-tap-login";
18
+ import * as Setting from "../forms/util/core";
19
+ import * as Provider from "./Provider";
20
+
21
+ function Icon({ width = 24, height = 24, color }) {
22
+ return (
23
+ <img
24
+ src={`${StaticBaseUrl}/buttons/google.svg`}
25
+ alt="Sign in with Google"
26
+ />
27
+ );
28
+ }
29
+
30
+ const config = {
31
+ text: "Sign in with Google",
32
+ icon: Icon,
33
+ iconFormat: (name) => `fa fa-${name}`,
34
+ style: { background: "#ffffff", color: "#000000" },
35
+ activeStyle: { background: "#eff0ee" },
36
+ };
37
+
38
+ const GoogleLoginButton = createButton(config);
39
+
40
+ export function GoogleOneTapLoginVirtualButton(prop) {
41
+ const application = prop.application;
42
+ const providerConf = prop.providerConf;
43
+ // https://stackoverflow.com/questions/62281579/google-one-tap-sign-in-ui-not-displayed-after-clicking-the-close-button
44
+ // document.cookie = "g_state=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT";
45
+ useGoogleOneTapLogin({
46
+ googleAccountConfigs: {
47
+ client_id: providerConf.provider.clientId,
48
+ },
49
+ onError: (error) => {
50
+ Setting.showMessage("error", error);
51
+ },
52
+ onSuccess: (response) => {
53
+ const code = "GoogleIdToken-" + JSON.stringify(response);
54
+ const authUrlParams = new URLSearchParams(
55
+ Provider.getAuthUrl(application, providerConf.provider, "signup")
56
+ );
57
+ const state = authUrlParams.get("state");
58
+ let redirectUri = authUrlParams.get("redirect_uri");
59
+ redirectUri = `${redirectUri}?state=${state}&code=${encodeURIComponent(
60
+ code
61
+ )}`;
62
+ Setting.goToLink(redirectUri);
63
+ },
64
+ disableCancelOnUnmount: false,
65
+ });
66
+ }
67
+
68
+ export default GoogleLoginButton;