Socialite Library throwing error curl_reset() undefined in laravel 5 - laravel-5

I am using socialite package with my laravel 5 project. I am hosting my site in hostgator. I have checked thrice that my php version in hostgator is 5.5.22 .
But still i am getting this error.
FatalErrorException in CurlFactory.php line 69:
Call to undefined function GuzzleHttp\Handler\curl_reset()
in CurlFactory.php line 69
I have tried Facebook as well as Google plus login using socialite but in both cases when redirects to my controller/function it throws this error.
Please help me. What can be possible errors
My Auth controller functions are
public function getFacebookLogin(){
return Socialite::driver('facebook')->redirect();
}
public function getHandleFbLogin(){
//echo "hey";
$user = Socialite::driver('facebook')->user();
print_r($user);
}
public function getGoogleLogin(){
return Socialite::driver('google')->redirect();
}
public function getHandleGpLogin(){
echo "hey";
$user = Socialite::driver('google')->user();
print_r($user);
}

I am very new to Stackoverflow. I also got stucked in this, so I did the following :-
Go to
/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
line no. 69 and replace
curl_reset($resource);
with
curl_setopt($resource, CURLOPT_HTTPGET, 1);
curl_setopt($resource, CURLOPT_POST, false);

Related

Laravel\Socialite\Two\InvalidStateException

Hi i am using laravel socialite for social logins with facebook and google and it absoultely working fine on my local server but when i deploy this on my web hosting it gives me error
Laravel\Socialite\Two\InvalidStateException
it is only for when i try to login with google in my app but it is working fine for facebook i tried many solutions as add stateless() in both google redirect method and callback method and single single too but all in vain i also tried to change in config/session where domain shows as null to my site name but again got same issue here is my code for google redirect and callback
public function redirectToGoogle()
{
return Socialite::driver('google')->redirect();
}
public function handleGoogleCallback()
{
$user = Socialite::driver('google')->user();
$this->_registerOrLoginUser($user);
return redirect()->route('home');
}
protected function _registerOrLoginUser($data)
{
$user = User::where('email','=',$data->email)->first();
if(!$user){
$user = new User();
$user->first_name = $data->name;
$user->email = $data->email;
// $user->provider_id = $data->provider_id;
$user->avatar = $data->avatar;
$user->save();
}
Auth::login($user);
}
please let me know if i'm missing something or doing wrong i'll appreciate your response in advance thank you

Laravel Jetstream Route Test With Inertia Returns Error Code 500

Out the test it works, I can visit the page and the controller wroks fine. I wrote the following test:
public function test_logged_user_is_not_redirected()
{
PartnerFactory::new()->create();
$request = $this->actingAs(UserFactory::new()->create())
->get('partners')
->assertRedirect('partners');
dd($request->inertiaProps());
}
I get error code 500. This is the controller:
public function index()
{
return Inertia::render('Partners/Index', [
'filters' => \Illuminate\Support\Facades\Request::all($this->getFilters()),
'contacts' => function() {
return $this->getAllContacts();
}
]);
}
This is the route in web.php
Route::get('partners', [PartnersController::class, 'index'])
->name('partners')
->middleware('auth');
Using refresh database, tried url with a '/' before, I still get 500.
edit: without exception handling i get: Trying to get property 'id' of non-object
Found the solution: The user in jetstream MUST have the personal team!

Laravel 404 Not Found - But Route Exists

Hello im trying to get information about user on my view.
Here is my UserController
public function getUser(Request $request, $id)
{
$user = User::findOrFail($id);
return view('admin.user', ['user' -> $user]);
}
here is my web.php
Route::get('admin/user/{id}', "UsersController#getUser");
and my user view
#extends('admin.layouts.app')
#section('contents')
<h1>User {{ $user }} </h1>
#endsection
I am trying to display user information in this view, like name etc, but im recives 404
Not Found page. What im doing wrong. Im using Laravel 6
404 error may refer to a User not being found, since you have a findOrFail() query. It may have nothing to do with your routes.
Just double check with:
php artisan route:list
just to make sure the route is being registered correctly.
I think you firstly use any prefix for this route.For this it will give you an error.To check route list.
php artisan route:list
it will give you all route.
And Here you don't need (Request $request) because here you just need the id.it not the problem..i give you just this suggestion
public function getUser($id)
{
$user = User::findOrFail($id);
return view('admin.user', ['user'=> $user]);
}
why you use '-> ' you should use '=>'

Not working Custom HTTP Error Pages in laravel 5.2

I use Laravel 5.2
I wanted to change this error :
Whoops, looks like something went wrong.
first please see : Laravel
I created a new file resources/views/errors/404.blade.php but my app error didn't change !
it change just when not found url at route but when insert url injection in to $_GET it show "whoops .." yet
for example work for this link : http://domain.com/dgdgergehrhddg54d6g8
but not working for this injection : http://domain.com/listmanage=8 insert 9 instens of 8
error message when debug is true :
ErrorException: file.php line 215
Trying to get property of non-object
You are viewing that error page because of the environment you are into.
As default, for local environments, the "Whoops" format is shown.
For Production environments, the error/x.blade.php files are used.
To customize this you simply go to: ./app/Exceptions/Handler.php
And modify the render function. You can do something like this:
public function render($request, Exception $e)
{
// If an ErrorException is received and this enviroment is local
if ($e instanceof \ErrorException && app()->environment() == 'local') {
// Show customized page
return response()->view('errors.404', [], $e->getCode());
}
return parent::render($request, $e);
}
Cheers :)
on Larvel 5.2 on your app/exceptions/handler.php just extend this method renderHttpException ie add this method to handler.php
/**
* Render the given HttpException.
*
* #param \Symfony\Component\HttpKernel\Exception\HttpException $e
* #return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e)
{
// to get status code ie 404, 503, 500
$status = $e->getStatusCode();
if (view()->exists("errors.{$status}")) {
return response()->view("errors.{$status}", ['exception' => $e], $status, $e->getHeaders());
} else {
return $this->convertExceptionToResponse($e);
}
}
Hope that helps.

Lumen is giving Blank Page with 500 Internal Error on Post

I have set the Lumen working. The debugging when hitting on a wrong route it gives a proper Laravel error log. However, when I try it with a Post route and it gives an 500 Internal Error, the page in network is blank. Chrome says This request has no response data available
My .env is
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomKey!!!
I am not sure if it's related with the host but I am using nginx with Digital Ocean.
I tried adding this in public/index.php, but no luck..
try {
$app->run();
} catch(\Exception $e) {
echo "<pre>";
echo $e;
echo "</pre>";
}
What may be the problem
Edit: The function I am trying to call:
public function index(Request $request) {
$a = $request->all();
foo($a)
}
private function foo($a) {
print($a)
}
Try this:
public function index(Request $request)
{
$a = $request->all();
$this->foo($a);
}
private function foo($a)
{
print_r($a);
}

Resources