How to check in a Vue component if a user is authenticated in Laravel?

前端 未结 4 1733
醉酒成梦
醉酒成梦 2021-02-04 07:49

As the title states, I\'m a little confused how I would tackle a method in my Vue Component with if/else statement based on if the user is logged in and authenticated with Larav

4条回答
  •  日久生厌
    2021-02-04 08:28

    I'm working with laravel 7+ and it doesn't need to send Auth::user() via controller Just call it from your laravel blade template file like below

    your-template-name.blade.php

    @if (Auth::check())
         
    @else
         
    @endif
    

    inside YourComponent.vue, store authUser like this:

    
    
                                     
                  
提交回复
热议问题