lundi 26 octobre 2020

Authentication In Laravel With Multi Auth

i am just learning the laravel version 5.4. i just made a simple blog post application using laravel with an website and admin panel

So in navbar which is common for front side code looks like below

@if (Auth::guest())
    <li><a href="">Login</a></li>
    <li><a href="">Register</a></li>
@else
    <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
             <span class="caret"></span>
        </a>
    </li>

And In controller

class PostController extends Controller
{
    public function __construct()
    {
        //$this->middleware('auth:user'); << i also tried thi
        $this->middleware('auth:user')->except('index','show');
    }

So the problem is i wants to allow all users to read blog post without login but if i add this middleware than user cant access this page without the login.

than i also tried to put except() keyword. after adding this it works but problem is in navbar it is still showing Login/Register instead showing logout button and profile name.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HsU4Q5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire