Laravel redirect if a user field is not 1 - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Sunday, September 24, 2023

Laravel redirect if a user field is not 1

In an layout.app I want to redirect users if a field in the user table is not one. I want to send them to a Members dashboard.

I have tried this in the top of my file

if (Auth::user()->admin <> 1)
{
    session()->flash('error','you are not authorised for the administration area');
    return redirect()->action([App\Http\Controllers\MembersController::class,'dashboard']);
}

but it does not redirect - I just get the session message.

Any help greatly appreciated!



source https://stackoverflow.com/questions/77164376/laravel-redirect-if-a-user-field-is-not-1

No comments:

Post a Comment