Home > Net >  laravel breeze authentication failed in request file but it's returns authenticated user in con
laravel breeze authentication failed in request file but it's returns authenticated user in con

Time:04-02

I'm using Laravel breeze as the back end and nextjs in front end.

First I login to site and every thing is correct.

When trying to insert a new order, in OrderRequest file I Check if the user is authenticated or not :

public function authorize()
{
    if(!Auth::check())
        return false;
}

this method always return false but if I bypass the authentication process and always return true and go to controller I can get the authenticated user info.

Why this happened? If the user is authenticated I have to recognize the user status in all sections.

CodePudding user response:

I solved the problem, Just by adding return true at the end of the method:

public function authorize()
{
    if(!Auth::check())
        return false;
    return true;
}
  • Related