Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

of course according to your middleware, if the user is logged in you will always be redirected to 'form'

what you need to do is implement the opposite of this.

0

ok... interesting.... I think I had a very big misunderstanding of how this works.

I may have almost gotten it now. Perhaps I should be asking a new question/starting a new thread, but I will continue here for now... I have it now so that the user clicks to go to "/form", then the authentication "interrupts" and redirects to my login page. But now, after login - it continues to direct me to the login page. I am sure my login is correct, nothing is showing up in the log. I'm not sure what to do to troubleshoot this next. If this sounds familiar to anyone, or if anyone can offer something for me to try, check, or read, I would very much appreciate it.

Thank you

0

I've finally figured it out!

So I've altered the code from above to read:

    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return $next($request);
        }

    }

And it turns out my troubles were a combination of: 1. my database being incorrectly setup, 2. this code being incorrect, and 3. my html form password input name being inconsistent with my db

yikes! well, it appears to be working well now! Thank you for the push in the right direction!

With all my routes, and Authenticate middleware setup, it will only ask for authentication when you go to the one webpage, it will leave you at the correct place after login (or registration), and you will be able to freely browse the full website! Just as I needed!

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.