0

I'm having some issues with protecting routes in Laraval.

So one of my routes: Route::get('/purchase-quote', ['middleware' => 'auth', 'uses' => 'PurchaseController@purchaseQuote']);

Lets say for example, I am on page /about and I click a link that takes me to /purchase-quote. Well it's doing what I want there, it's forcing someone to login or register before accessing the page.

The issue is that after they register, instead of continuing on and taking them to the intended /purchase-quote page, it takes them directly to the home page at /

This used to work the way I am needing it to, and all of a sudden it does not. If I do login instead of register, it works the way it should.

Will also include auth code here:

public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->guest()) {
            if ($request->ajax() || $request->wantsJson()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()->guest('register');
            }
        }
        return $next($request);
    }
lpangm03
  • 99
  • 8
  • 1
    This might be the answer you are looking for: http://stackoverflow.com/a/15393229/1561929 – Alex Harris Oct 20 '16 at 15:08
  • It is, and that is what I have actually, which is what makes me not sure why this is happening. Here is what I have for the auth code: public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->guest()) { if ($request->ajax() || $request->wantsJson()) { return response('Unauthorized.', 401); } else { return redirect()->guest('register'); } } return $next($request); } – lpangm03 Oct 20 '16 at 15:10
  • maybe you can put that code in your original question? – Alex Harris Oct 20 '16 at 15:12
  • I modified my original with it. – lpangm03 Oct 20 '16 at 15:15

0 Answers0