diff --git a/src/app/Http/Controllers/LoginController.php b/src/app/Http/Controllers/LoginController.php new file mode 100644 index 0000000..aadb9fb --- /dev/null +++ b/src/app/Http/Controllers/LoginController.php @@ -0,0 +1,37 @@ +userRepository->findByUsername(new Username($request->username())); + + $payload = AdminInitiateAuthPayload::createForAdminUserPasswordAuthFlow($user->username(), $request->password()); + $this->adminInitiateAuth->execute($payload); + + Auth::loginUsingId($user->userId()); + Session::regenerate(); + Session::regenerateToken(); + + return redirect()->route('dashboard'); + } +} diff --git a/src/app/Http/Requests/LoginRequest.php b/src/app/Http/Requests/LoginRequest.php new file mode 100644 index 0000000..35bc6a6 --- /dev/null +++ b/src/app/Http/Requests/LoginRequest.php @@ -0,0 +1,28 @@ + ['required', 'string'], + 'password' => ['required', 'string'], + ]; + } + + public function username(): string + { + return $this->input('username'); + } + + public function password(): string + { + return $this->input('password'); + } +} diff --git a/src/resources/views/login.blade.php b/src/resources/views/login.blade.php new file mode 100644 index 0000000..2e8b784 --- /dev/null +++ b/src/resources/views/login.blade.php @@ -0,0 +1,14 @@ +@extends('layouts.app') + +@section('title', 'ログイン') + +@section('content') +