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