'Google login integration not working, redirect to homepage without no profile
It was works fine. But problem arise after migrating domain & hosting. When I tried to login/signup with google login, it connect with Client ID & Secret correctly. But after, it redirect to homepage without any data or profile showing. On other side, same Client ID & Secret works fine in localhost.
Route::post('googlelogin', 'Api\Auth\LoginController@googlelogin');
#Controller
public function googlelogin(Request $request){
$this->validate($request, [
'email' => 'required',
'name' => 'required',
'uid' => 'required',
'password' => ''
]);
$authUser = User::where('email', $request->email)->first();
if($authUser){
$authUser->google_id = $request->uid;
$authUser->fname = $request->name;
$authUser->save();
if(isset($authUser) && $authUser->status == '0'){
return response()->json('Blocked User', 401);
}
else{
if (Hash::check('password', $authUser->password)) {
return $response = $this->issueToken($request,'password');
} else {
$response = ["message" => "Password mismatch"];
return response($response, 422);
}
}
}
else{
$verified = \Carbon\Carbon::now()->toDateTimeString();
$user = User::create([
'fname' => request('name'),
'email' => request('email'),
'password' => Hash::make($request->password !='' ? $request->password : 'password'),
'google_id' => request('uid'),
'status'=>'1',
'email_verified_at' => $verified
]);
return $response = $this->issueToken($request, 'password');
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

