codenitive / laravel-oneauth

OAuth and OAuth2 Auth bundle for Laravel

Home Page:http://bundles.laravel.com/bundle/oneauth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Controller::action_error()

deivian opened this issue · comments

I've been playing with this bundle and found myself with this issue when cancelling the authorization to login with facebook. When creating the controller if I create the action action_error($provider, $e), Laravel throws this exception:

Message:
Declaration of Connect_Controller::action_error() should be compatible with that of OneAuth\Auth\Controller::action_error()
Location:
/Applications/MAMP/htdocs/mark05/application/controllers/connect.php on line 4

And if there is no action_error() of course I receive the exception with the information about why it failed.

Message:
{"error":{"message":"Missing authorization code","type":"OAuthException","code":1}}
Location:
/Applications/MAMP/htdocs/mark05/bundles/oneauth/libraries/oauth2/core.php on line 65

Don't know the reason but I'm unable to handle the error from the controller, thank you for your help

I found the issue for the first exception due I was creation the function action_error() incorrectly but I'm unable to handle the message error, how can I send the error message to a view?

You can do the following:

public function action_error($provider = null, $e = '')
{
    // $e would be the value of Exception::getMessage() from Facebook/OneAuth
    return View::make('your.error.view', array('data' => $e));
}

For some reason I can't understand even if I add the action_error function to my controller I still see the unhandled exception on screen. This happens when I don't allow the Facebook Application to acces the facebook profile, no problem with Twitter, but with Facebook this fails.

I see the controller redirecting properly to /[controller]/callback/facebook with some get variables:

/connect/callback/facebook?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&state=21fsadf33534523496e8e6c595a16abeef2be6#_=_

But as I said before the action_error on the controller is not executed, instead the Exception occurs.

I'll try to replicate your case.

Above code should solve the problem. Thanks for the report and feel free to reopen this if you still having problem.

solved :)