From 8cb316bb33f745de510bcc28f7fa964e64e088cf Mon Sep 17 00:00:00 2001 From: ucan-lab <35098175+ucan-lab@users.noreply.github.com> Date: Fri, 30 Jun 2023 19:01:57 +0900 Subject: [PATCH] Login --- src/app/Http/Controllers/LoginController.php | 37 ++++++++++++++++++++ src/app/Http/Requests/LoginRequest.php | 28 +++++++++++++++ src/resources/views/login.blade.php | 14 ++++++++ src/routes/web.php | 3 ++ 4 files changed, 82 insertions(+) create mode 100644 src/app/Http/Controllers/LoginController.php create mode 100644 src/app/Http/Requests/LoginRequest.php create mode 100644 src/resources/views/login.blade.php 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') +