Hi again,
Question about logout:
I can do this in the frontend: this.$auth.logout();
But how to logout the laravel backend?
I have tried:
Nuxt: logout() { this.$axios.$post(process.env.LARAVEL_ENDPOINT+'/api/logout') .then(response => {.....
Laravel backend:
API.php *******************
Route::middleware('auth:api')->group(function () { Route::post('logout', 'Auth\AuthWepAppController@logoutApi')->name('logout'); });
AuthWepAppController *******************
public function logoutApi (Request $request) { $token = $request->user()->token(); $token->revoke(); $response = 'You have been succesfully logged out!'; return response($response, 200); }
It gives me this error: message": "Call to undefined method Illuminate\Support\Facades\Request::user()",
What am I missing? thanks
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi again,
Question about logout:
I can do this in the frontend: this.$auth.logout();
But how to logout the laravel backend?
I have tried:
Nuxt:
logout() {
this.$axios.$post(process.env.LARAVEL_ENDPOINT+'/api/logout')
.then(response => {.....
Laravel backend:
API.php *******************
Route::middleware('auth:api')->group(function () {
Route::post('logout', 'Auth\AuthWepAppController@logoutApi')->name('logout');
});
AuthWepAppController *******************
It gives me this error:
message": "Call to undefined method Illuminate\Support\Facades\Request::user()",
What am I missing? thanks