I want to create user by using social authentication like facebook authentication and i followed this tutorial [Sociolite Authentication in Laravel 5.1][1]
[1]: https://www.youtube.com/watch?v=NZWJCoXN6Us&list=PLpRNkmPv_dKHoicxrsB8QVMYjeKoEiCWK&index=24 from youtube
after using this tutorial i got an Exception which is
BadMethodCallException in Controller.php line 283:
Method [create] does not exist.
in Controller.php line 283
at Controller->__call('create', array(array('name' => null, 'email' => 'abdur.razzaq06@gmail.com', 'password' => '4dbf14f26a97584375b7b2c84b6a4786cb1b4a43'))) in SocialAuthController.php line 84
at SocialAuthController->create(array('name' => null, 'email' => 'abdur.razzaq06@gmail.com', 'password' => '4dbf14f26a97584375b7b2c84b6a4786cb1b4a43')) in SocialAuthController.php line 84
at SocialAuthController->github_Callback()
at call_user_func_array(array(object(SocialAuthController), 'github_Callback'), array()) in Controller.php line 256
at Controller->callAction('github_Callback', array()) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(SocialAuthController), object(Route), 'github_Callback') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
what can i do now plz help me ...?????
hare is my code
app\routes.php
// facebook Sociolite
Route::get('/auth/facebook', 'Auth\SocialAuthController@redirectToProvider');
Route::get('callback_facebook', 'Auth\SocialAuthController@handleProviderCallback');
App\Http\Auth|SocialAuthController.php
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Foundation\Validation\ValidatesRequests;
use App\User;
use Validator;
//use ValidatesRequests;
use Socialite;
use Auth;
use redirect;
class SocialAuthController extends Controller
{
// For Facebook
public function redirectToProvider(){
return Socialite::driver('facebook')->redirect();
}
public function handleProviderCallback(){
$curl = curl_init();
curl_setopt($curl , CURLOPT_SSL_VERIFYPEER, false);
$user = Socialite::driver('facebook')->user();
$data = ['name'=>$user->name, 'email'=>$user->email, 'password'=>$user->token];
$userDB = User::where('email',$user->email)->first();
if (!is_null($userDB)){
Auth::login($userDB);
}
else{
Auth::login($this->create($data)); // line 84
// Auth::login($this->data($data));
}
return redirect('/pages/profile');
}
}
vendor/laravel/framework/src/Illuminate/Routing/Controller.php
<?php
namespace Illuminate\Routing;
use Closure;
use BadMethodCallException;
use Illuminate\Support\Str;
use InvalidArgumentException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
abstract class Controller
{
public function __call($method, $parameters)
{
throw new BadMethodCallException("Method [$method] does not exist."); // line 283
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire