@@ -13,46 +13,46 @@ import { FaGithub } from "react-icons/fa";
1313import { useRouter , useSearchParams } from "next/navigation" ;
1414
1515export default function GitHubAuth ( ) {
16- const router = useRouter ( ) ;
17- const searchParams = useSearchParams ( ) ;
18- const redirect = searchParams . get ( "redirectTo" ) ;
19- const { toast } = useToast ( ) ;
16+ const router = useRouter ( ) ;
17+ const searchParams = useSearchParams ( ) ;
18+ const redirect = searchParams . get ( "redirectTo" ) ;
19+ const { toast } = useToast ( ) ;
2020
21- const login = async ( ) => {
22- try {
23- await ccdSignInWithPopUp ( provider ) ;
24- redirect
25- ? router . replace (
26- redirect === "/pro" ? `${ redirect } ?showSubscribe=true` : redirect
27- )
28- : router . replace ( "/dashboard" ) ;
29- } catch ( err : any ) {
30- if ( err instanceof FirebaseError ) {
31- if ( err . code === "auth/account-exists-with-different-credential" ) {
32- toast ( {
33- variant : "destructive" ,
34- description :
35- "Account Exists with Different Login Method. Please first login and then link within your Account page." ,
36- } ) ;
37- } else {
38- toast ( {
39- variant : "destructive" ,
40- description : err . message ,
41- } ) ;
42- }
43- } else {
44- toast ( {
45- variant : "destructive" ,
46- description : JSON . stringify ( err ) ,
47- } ) ;
48- console . error ( err ) ;
49- }
50- }
51- } ;
21+ const login = async ( ) => {
22+ try {
23+ await ccdSignInWithPopUp ( provider ) ;
24+ redirect
25+ ? router . replace (
26+ redirect === "/pro" ? `${ redirect } ?showSubscribe=true` : redirect ,
27+ )
28+ : router . replace ( "/dashboard" ) ;
29+ } catch ( err : any ) {
30+ if ( err instanceof FirebaseError ) {
31+ if ( err . code === "auth/account-exists-with-different-credential" ) {
32+ toast ( {
33+ variant : "destructive" ,
34+ description :
35+ "Account Exists with Different Login Method. Please first login and then link within your Account page." ,
36+ } ) ;
37+ } else {
38+ toast ( {
39+ variant : "destructive" ,
40+ description : err . message ,
41+ } ) ;
42+ }
43+ } else {
44+ toast ( {
45+ variant : "destructive" ,
46+ description : JSON . stringify ( err ) ,
47+ } ) ;
48+ console . error ( err ) ;
49+ }
50+ }
51+ } ;
5252
53- return (
54- < Button onClick = { login } variant = "secondary" >
55- < FaGithub className = "mr-2 h-4 w-4" /> Login with GitHub
56- </ Button >
57- ) ;
53+ return (
54+ < Button onClick = { login } variant = "secondary" >
55+ < FaGithub className = "mr-2 h-4 w-4" /> Login with GitHub
56+ </ Button >
57+ ) ;
5858}
0 commit comments