diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 362ef6c..b44d9d4 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -36,6 +36,25 @@ public function create(Request $request, RegisterUserService $service) } DB::commit(); - return response()->json(['message' => 'success']); + return redirect()->route('user.create'); + } + + public function login(Request $request) + { + $request->validate( + [ + 'email' => 'required|email', + 'password' => 'required', + ] + ); + + $user = DB::table('users')->where('email', $request->input('email'))->first(); + + if ($user && $user->password === $request->input('password')) { + $request->session()->put('user', $user); + return redirect()->route('user.login'); + } + + return redirect()->route('user.login'); } } diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php new file mode 100644 index 0000000..22b351f --- /dev/null +++ b/resources/views/auth/login.blade.php @@ -0,0 +1,62 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Register') }}
+ +
+
+ @csrf + +
+ + +
+ + + @error('email') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + @error('password') + + {{ $message }} + + @enderror +
+
+ + +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php new file mode 100644 index 0000000..05c2f2c --- /dev/null +++ b/resources/views/auth/register.blade.php @@ -0,0 +1,83 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Register') }}
+ +
+
+ @csrf + +
+ + +
+ + + @error('name') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + @error('email') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + @error('password') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + @error('image') + + {{ $message }} + + @enderror +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php new file mode 100644 index 0000000..7a9522c --- /dev/null +++ b/resources/views/layouts/app.blade.php @@ -0,0 +1,84 @@ + + + + + + + + {{ config('app.name', 'Laravel') }} + + + + + + + + {{-- Bootstrap Icons --}} + + + + + + + +
+ + +
+ @yield('content') +
+
+ + + diff --git a/routes/web.php b/routes/web.php index d259f33..8df8c99 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,6 @@ name('register'); +Route::get('/register', function () { + return view('auth.register'); +})->name('user.create'); + +Route::post('/login', [UserController::class, 'login'])->name('login'); +Route::get('/login', function () { + return view('auth.login'); +})->name('user.login');