i using laravel 5 , jwt-auth package handle jwt. how authenticate if user came facebook?
my idea is, i'm going authenticate using fb id , email. did changing password fb_id, unfortunately didn't work. recommendation , why error below? thanks!
authentication code:
//facebook if(input::has('fb_id')){ $credentials = input::only('email','fb_id'); }else{ $credentials = input::only('email', 'password'); } try { // attempt verify credentials , create token user if (! $token = jwtauth::attempt($credentials)) { return response::json(['error' => 'invalid_credentials'], 401); } } catch (jwtexception $e) { // went wrong whilst attempting encode token return response::json(['error' => 'could_not_create_token'], 500); }
error:
errorexception in eloquentuserprovider.php line 108: undefined index: password
update: managed make work using jwtauth::fromuser($user).
//find user using details. $user = user::where('email','=',input::get('email'))->where('fb_token','=',input::get('fb_id'))->first(); //then use $token = jwtauth::fromuser($user);
Comments
Post a Comment