File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 7
7
use App \Http \Requests \UserRequest ;
8
8
use App \Models \User ;
9
9
use Illuminate \Support \Facades \Auth ;
10
+ use Illuminate \Support \Facades \Cookie ;
10
11
use Illuminate \Support \Facades \Hash ;
11
12
use Symfony \Component \HttpFoundation \Response ;
12
13
@@ -47,4 +48,12 @@ public function user()
47
48
return Auth::user ();
48
49
}
49
50
51
+ public function logout ()
52
+ {
53
+ $ cookie = Cookie::forget ('jwt ' );
54
+
55
+ return response ([
56
+ 'message ' => 'Logged out successfully '
57
+ ])->withCookie ($ cookie );
58
+ }
50
59
}
Original file line number Diff line number Diff line change 5
5
6
6
Route::post ('register ' , [AuthController::class, 'register ' ]);
7
7
Route::post ('login ' , [AuthController::class, 'login ' ]);
8
- Route::post ('logout ' , [AuthController::class, 'logout ' ]);
9
8
10
9
Route::middleware ('auth:sanctum ' )->group (function () {
11
10
Route::get ('user ' , [AuthController::class, 'user ' ]);
11
+ Route::post ('logout ' , [AuthController::class, 'logout ' ]);
12
12
});
You can’t perform that action at this time.
0 commit comments