Skip to content
Advertisement

laravel breeze authentication failed in request file but it’s returns authenticated user in controller

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.

Advertisement

Answer

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;
}
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement