diff --git a/app/Http/Controllers/LoginController.php b/app/Http/Controllers/LoginController.php index 9461ca3e..6e4dd9d0 100644 --- a/app/Http/Controllers/LoginController.php +++ b/app/Http/Controllers/LoginController.php @@ -3,20 +3,13 @@ namespace App\Http\Controllers; use App\Actions\StoreSpaceInSessionAction; +use App\Models\LoginAttempt; use App\Models\User; -use App\Repositories\LoginAttemptRepository; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; class LoginController extends Controller { - private $loginAttemptRepository; - - public function __construct(LoginAttemptRepository $loginAttemptRepository) - { - $this->loginAttemptRepository = $loginAttemptRepository; - } - public function index() { return view('login'); @@ -32,7 +25,12 @@ public function store(Request $request) ) { $user = Auth::user(); - $this->loginAttemptRepository->create($user->id, $request->ip(), false); + LoginAttempt::query() + ->create([ + 'user_id' => $user->id, + 'ip' => $request->ip(), + 'failed' => false, + ]); (new StoreSpaceInSessionAction())->execute($user->spaces[0]->id); @@ -41,7 +39,12 @@ public function store(Request $request) if ($request->input('email')) { $user = User::where('email', $request->input('email'))->first(); - $this->loginAttemptRepository->create($user ? $user->id : null, $request->ip(), true); + LoginAttempt::query() + ->create([ + 'user_id' => $user ? $user->id : null, + 'ip' => $request->ip(), + 'failed' => true, + ]); } $request->flash(); diff --git a/app/Http/Controllers/RegisterController.php b/app/Http/Controllers/RegisterController.php index d6d39bf4..8edf39aa 100644 --- a/app/Http/Controllers/RegisterController.php +++ b/app/Http/Controllers/RegisterController.php @@ -6,25 +6,22 @@ use App\Actions\StoreSpaceInSessionAction; use App\Actions\SendVerificationMailAction; use App\Models\Currency; +use App\Models\LoginAttempt; use App\Models\User; use Illuminate\Http\Request; // use App\Http\Controllers\Controller; -use App\Repositories\LoginAttemptRepository; use App\Repositories\SpaceRepository; use Illuminate\Support\Facades\Auth; class RegisterController extends Controller { private $spaceRepository; - private $loginAttemptRepository; public function __construct( SpaceRepository $spaceRepository, - LoginAttemptRepository $loginAttemptRepository ) { $this->spaceRepository = $spaceRepository; - $this->loginAttemptRepository = $loginAttemptRepository; } public function index() @@ -54,7 +51,12 @@ public function store(Request $request) Auth::loginUsingId($user->id); - $this->loginAttemptRepository->create($user->id, $request->ip(), false); + LoginAttempt::query() + ->create([ + 'user_id' => $user->id, + 'ip' => $request->ip(), + 'failed' => false, + ]); (new StoreSpaceInSessionAction())->execute($user->spaces[0]->id); diff --git a/app/Repositories/LoginAttemptRepository.php b/app/Repositories/LoginAttemptRepository.php deleted file mode 100644 index e242b292..00000000 --- a/app/Repositories/LoginAttemptRepository.php +++ /dev/null @@ -1,17 +0,0 @@ - $userId, - 'ip' => $ip, - 'failed' => $failed - ]); - } -}