@@ -25,20 +25,25 @@ const LoginForm = ({ redirectPath }: LoginFormProps) => {
2525 const { mutateAsync, isPending } = useMutation ( {
2626 mutationFn : ( payload : ILoginPayload ) => loginAction ( payload , redirectPath ) ,
2727 } ) ;
28- const handleGoogleLogin = async ( ) => {
29- const res = await fetch ( `${ process . env . NEXT_PUBLIC_BACKEND_URL } /api/auth/sign-in/social` , {
30- method : "POST" ,
31- headers : { "Content-Type" : "application/json" } ,
32- credentials : "include" ,
33- body : JSON . stringify ( {
34- provider : "google" ,
35- callbackURL : "https://cinetube.arifuddincoder.site/dashboard" ,
36- } ) ,
37- } ) ;
38- const data = await res . json ( ) ;
39- if ( data . url ) {
40- window . location . href = data . url ;
41- }
28+ const handleGoogleLogin = ( ) => {
29+ const form = document . createElement ( "form" ) ;
30+ form . method = "POST" ;
31+ form . action = `${ process . env . NEXT_PUBLIC_BACKEND_URL } /api/auth/sign-in/social` ;
32+
33+ const provider = document . createElement ( "input" ) ;
34+ provider . type = "hidden" ;
35+ provider . name = "provider" ;
36+ provider . value = "google" ;
37+
38+ const callbackURL = document . createElement ( "input" ) ;
39+ callbackURL . type = "hidden" ;
40+ callbackURL . name = "callbackURL" ;
41+ callbackURL . value = "https://cinetube.arifuddincoder.site/dashboard" ;
42+
43+ form . appendChild ( provider ) ;
44+ form . appendChild ( callbackURL ) ;
45+ document . body . appendChild ( form ) ;
46+ form . submit ( ) ;
4247 } ;
4348 const form = useForm ( {
4449 defaultValues : { email : "" , password : "" } ,
0 commit comments