From 28f62d300565c83212363d63f12bc9743fd85189 Mon Sep 17 00:00:00 2001 From: Jan_Hill Date: Fri, 20 Dec 2024 02:43:06 +0100 Subject: [PATCH] modified: app/Http/Controllers/AuthController.php modified: app/Http/Controllers/SmartController.php new file: resources/views/smart/dashboard.blade.php modified: resources/views/smart/login.blade.php --- app/Http/Controllers/AuthController.php | 12 +++++++---- app/Http/Controllers/SmartController.php | 5 +++++ resources/views/smart/dashboard.blade.php | 25 +++++++++++++++++++++++ resources/views/smart/login.blade.php | 24 +++++++++++++++++++++- 4 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 resources/views/smart/dashboard.blade.php diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 37edbca..aa6e0d7 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -12,14 +12,18 @@ class AuthController extends Controller { try { $credits = $request->validate([ - "email" => "required|email", - "password" => "required" + "email" => "required|email", + "password" => "required" ]); if (Auth::attempt(["email" => $credits["email"], "password" => $credits["password"]])) { - $user = Auth::user(); + $user = Auth::user(); - return response()->json(["account" => $user->name], 200); + return response()->json([ + "account" => $user->name, + "redirect" => "3000", + "message" => "Login successful. Redirecting in 3 seconds..." + ], 200); } return response()->json(["error" => "Invalid email or password."], 401); diff --git a/app/Http/Controllers/SmartController.php b/app/Http/Controllers/SmartController.php index 240c670..ee23a7a 100644 --- a/app/Http/Controllers/SmartController.php +++ b/app/Http/Controllers/SmartController.php @@ -10,4 +10,9 @@ class SmartController extends Controller { return view('smart.login'); } + + public function dashboard() + { + return view('smart.dashboard'); + } } diff --git a/resources/views/smart/dashboard.blade.php b/resources/views/smart/dashboard.blade.php new file mode 100644 index 0000000..bd84366 --- /dev/null +++ b/resources/views/smart/dashboard.blade.php @@ -0,0 +1,25 @@ + + + + @vite(['resources/css/app.css','resources/js/app.js']) + + NCORE - Dashboard + + \ No newline at end of file diff --git a/resources/views/smart/login.blade.php b/resources/views/smart/login.blade.php index edfe90d..bebdc2b 100644 --- a/resources/views/smart/login.blade.php +++ b/resources/views/smart/login.blade.php @@ -2,7 +2,26 @@ @vite(['resources/css/app.css','resources/js/app.js']) + NCORE - Authentication + @@ -60,7 +79,10 @@ Swal.fire({ title: "Success!", text: "You are Logged in as " + response.data.account, - icon: "success" + icon: "success", + timer: response.data.redirect + }).then(() => { + window.location.href = "{{ route('dashboard') }}"; }); console.log(response); })