InvalidArgumentException: Cannot redirect to an empty URL.

Issue #10 resolved
Jon Whittlestone created an issue

Hi. Thanks for this, good work.

I have all this up and running and successfully attempted and completed a LinkedIn registration on my localhost.

The recordsets in user and profile tables have been inserted succesfully but I then get an InvalidArgumentException: Cannot redirect to an empty URL

Any ideas? Is it because I haven't put into use the route: /anvard/endpoint? Where would I be specifying this? In the LinkedIn application details?

Clutching at straws I changed the MAMP port from 8888 back to 80 as I thought maybe it had something to do with the base_url in HybridAuth but that didn't do anything.

Thanks a lot

Jon

Comments (7)

  1. Jon Whittlestone reporter

    Update: In routes..php, According to the log, it seems to get up to

    Log::debug('Anvard: login success');
    Auth::loginUsingId($profile->user->id);
    

    But the stops there. I was using database auth instead of Eloquent so I changed that to ORM, but I'm still getting this error.

    Thx

  2. Matthew Ruddy

    Having this issue also, not just for LinkedIn but Twitter & Facebook also. Tried altering the routes in hybridauth.php but couldn't figure out a solution.

    Uncommenting the "base_url" property in hybridauth.php gives me a new error:

    Unable to generate a URL for the named route "anvard/login/{provider}" as such route does not exist.
    

    Stuck on this one.

  3. Peter Olson

    I think this happends because the route does a Redirect::back() but if your coming from an external site (like google/facebook/twitter when you authorized)... there is no where to go back too.

    In the latest update, I added a config option where you can set a default redirect after login (see https://bitbucket.org/atticmedia/anvard/src/0305969990bb879f15547e79f56d72a82e98e785/src/config/routes.php?at=master).

    I also added the ability to set a set a redirect url in the users SESSION. See the routes.php:

                /**
                 * added the detection / redirection script for easier customization
                 */
                if(Session::has('login_redirect_url')) {
                    $redirect_url = Session::get('login_redirect_url');
                    Session::forget('login_redirect_url');
                    return Redirect::to($redirect_url);
                }
    

    If you set login_redirect_url in SESSION before sending the user to facebook for authorization, the user will get redirected to that url after authorization.

  4. Log in to comment