diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index 59e0be56..7acd3e72 100644 --- a/app/Actions/Fortify/CreateNewUser.php +++ b/app/Actions/Fortify/CreateNewUser.php @@ -33,7 +33,6 @@ class CreateNewUser implements CreatesNewUsers ])->validate(); $user = User::create([ - 'name' => $input['name'], 'email' => $input['email'], 'password' => Hash::make($input['password']), ]); diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 240c630c..0511fd4f 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -101,30 +101,6 @@ class AuthController extends Controller return $response; } - /** - * Logout user entity - * - * @return \Illuminate\Http\JsonResponse - */ - public function logout() - { - // Demo preview - if (is_demo(Auth::id())) { - return response('Logout successfull', 204) - ->cookie('access_token', '', -1); - } - - // Get user tokens and remove it - auth()->user()->tokens()->each(function ($token) { - - // Remove tokens - $token->delete(); - }); - - return response('Logout successful', 204) - ->cookie('access_token', '', -1); - } - /** * Make login request for get access token * diff --git a/routes/user.php b/routes/user.php index d9b12d73..275de4da 100644 --- a/routes/user.php +++ b/routes/user.php @@ -17,7 +17,6 @@ Route::group(['middleware' => ['auth:sanctum']], function () { Route::get('/subscription', [SubscriptionController::class, 'show']); Route::get('/invoices', [AccountController::class, 'invoices']); Route::get('/storage', [AccountController::class, 'storage']); - Route::get('/logout', [AuthController::class, 'logout']); Route::get('/', [AccountController::class, 'user']); // Payment cards diff --git a/tests/Feature/AuthTest.php b/tests/Feature/AuthTest.php index e4cd53c8..5704996d 100644 --- a/tests/Feature/AuthTest.php +++ b/tests/Feature/AuthTest.php @@ -70,4 +70,18 @@ class AuthTest extends TestCase 'password' => 'secret', ])->assertStatus(200); } + + /** + * @test + */ + public function it_logout_user() + { + $user = User::factory(User::class) + ->create(); + + Sanctum::actingAs($user); + + $this->postJson('/logout') + ->assertStatus(204); + } }