This commit is contained in:
parent
c1cd9062f6
commit
a11069e7a2
|
|
@ -10,45 +10,45 @@ import { OAuthButton } from "../oauth-button";
|
||||||
//type OAuthStrategy = 'oauth_google' | 'oauth_github';
|
//type OAuthStrategy = 'oauth_google' | 'oauth_github';
|
||||||
|
|
||||||
export function OAuthSignIn() {
|
export function OAuthSignIn() {
|
||||||
const [isLoading, setIsLoading] = React.useState<OAuthStrategy | null>(null);
|
// const [isLoading, setIsLoading] = React.useState<OAuthStrategy | null>(null);
|
||||||
const { signIn, isLoaded: signInLoaded } = useSignIn();
|
// const { signIn, isLoaded: signInLoaded } = useSignIn();
|
||||||
|
|
||||||
const oauthSignIn = async (provider: OAuthStrategy) => {
|
// const oauthSignIn = async (provider: OAuthStrategy) => {
|
||||||
if (!signInLoaded) {
|
// if (!signInLoaded) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
try {
|
// try {
|
||||||
setIsLoading(provider);
|
// setIsLoading(provider);
|
||||||
await signIn.authenticateWithRedirect({
|
// await signIn.authenticateWithRedirect({
|
||||||
strategy: provider,
|
// strategy: provider,
|
||||||
redirectUrl: "/auth/sso-callback",
|
// redirectUrl: "/auth/sso-callback",
|
||||||
redirectUrlComplete: "/app/apis",
|
// redirectUrlComplete: "/app/apis",
|
||||||
});
|
// });
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
console.error(err);
|
// console.error(err);
|
||||||
setIsLoading(null);
|
// setIsLoading(null);
|
||||||
toast.error((err as Error).message);
|
// toast.error((err as Error).message);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
return (
|
// return (
|
||||||
<div className="flex flex-col gap-2">
|
// <div className="flex flex-col gap-2">
|
||||||
<OAuthButton onClick={() => oauthSignIn("oauth_github")}>
|
// <OAuthButton onClick={() => oauthSignIn("oauth_github")}>
|
||||||
{isLoading === "oauth_github" ? (
|
// {isLoading === "oauth_github" ? (
|
||||||
<Loading className="w-6 h-6" />
|
// <Loading className="w-6 h-6" />
|
||||||
) : (
|
// ) : (
|
||||||
<IconGitHub className="w-6 h-6" />
|
// <IconGitHub className="w-6 h-6" />
|
||||||
)}
|
// )}
|
||||||
GitHub
|
// GitHub
|
||||||
</OAuthButton>
|
// </OAuthButton>
|
||||||
<OAuthButton onClick={() => oauthSignIn("oauth_google")}>
|
// <OAuthButton onClick={() => oauthSignIn("oauth_google")}>
|
||||||
{isLoading === "oauth_google" ? (
|
// {isLoading === "oauth_google" ? (
|
||||||
<Loading className="w-6 h-6" />
|
// <Loading className="w-6 h-6" />
|
||||||
) : (
|
// ) : (
|
||||||
<IconGoogle className="w-6 h-6" />
|
// <IconGoogle className="w-6 h-6" />
|
||||||
)}
|
// )}
|
||||||
Google
|
// Google
|
||||||
</OAuthButton>
|
// </OAuthButton>
|
||||||
</div>
|
// </div>
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue