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') +