Laravel and removing redirects from output

I am trying to add a function

public function postLogout() {
    //Auth::logout();
    return response()->json(['msg' => 'You have signed out']);
}

to file

\vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php

and use the route

Route::get('log_out', ['as' => 'auth.log_out', 'uses' => 'Auth\AuthController@postLogout']);

How to switch to automatic redirection with url http: // localhost / myproj / public / log_out in these cases ??? thank you

+4
source share
1 answer

What do you mean by automation? You want to release the user and redirect him, right? You can redirect and blink a message at the same time, which makes sense in this scenario.

Route::get('log_out', function () {
   //Auth::logout();
   return redirect('log_in')->with('status', 'You have signed out!');
});

More here

+3
source

Source: https://habr.com/ru/post/1613941/


All Articles