@@ -17,6 +17,7 @@ import { useRouter } from "next/navigation";
1717import { DISABLE_ANONYMOUS_AUTH } from "@/lib/utils" ;
1818import { FcGoogle } from "react-icons/fc" ;
1919import { FaGithub } from "react-icons/fa" ;
20+ import { toast } from "sonner" ;
2021export default function AuthPage ( ) {
2122 const [ isLoading , setIsLoading ] = useState ( false ) ;
2223
@@ -25,10 +26,18 @@ export default function AuthPage() {
2526 const handleGitHubSignIn = async ( ) => {
2627 setIsLoading ( true ) ;
2728 try {
28- await authClient . signIn . social ( {
29+ const res = await authClient . signIn . social ( {
2930 provider : "github" ,
3031 callbackURL : "/pad" ,
3132 } ) ;
33+
34+ if ( res . error ) {
35+ if ( res . error . code === "PROVIDER_NOT_FOUND" ) {
36+ toast ( `Google sign in is disabled due to not configured.` ) ;
37+ }
38+ console . log ( "sign in error:" , res . error ) ;
39+ return ;
40+ }
3241 } catch ( error ) {
3342 console . error ( "Sign in error:" , error ) ;
3443 } finally {
@@ -43,7 +52,14 @@ export default function AuthPage() {
4352 }
4453 setIsLoading ( true ) ;
4554 try {
46- await authClient . signIn . anonymous ( ) ;
55+ const res = await authClient . signIn . anonymous ( ) ;
56+ if ( res . error ) {
57+ if ( res . error . code === "PROVIDER_NOT_FOUND" ) {
58+ toast ( `Google sign in is disabled due to not configured.` ) ;
59+ }
60+ console . log ( "sign in error:" , res . error ) ;
61+ return ;
62+ }
4763 router . refresh ( ) ;
4864 router . push ( "/pad" ) ;
4965 } catch ( error ) {
@@ -56,12 +72,20 @@ export default function AuthPage() {
5672 async function handleGoogleSignIn ( ) {
5773 setIsLoading ( true ) ;
5874 try {
59- await authClient . signIn . social ( {
75+ const res = await authClient . signIn . social ( {
6076 provider : "google" ,
6177 callbackURL : "/pad" ,
6278 } ) ;
63- } catch ( error ) {
64- console . error ( "Google sign in error:" , error ) ;
79+
80+ if ( res . error ) {
81+ if ( res . error . code === "PROVIDER_NOT_FOUND" ) {
82+ toast ( `Google sign in is disabled due to not configured.` ) ;
83+ }
84+ console . log ( "sign in error:" , res . error ) ;
85+ return ;
86+ }
87+ } catch ( error : any ) {
88+ console . log ( "Google sign in error:" , error ) ;
6589 } finally {
6690 setIsLoading ( false ) ;
6791 }
0 commit comments