diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 47359ce..cae8b7d 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -15,6 +15,12 @@ class LoginController extends Controller */ public function show() { + $centralDomains = config('tenancy.central_domains', []); + + if (in_array(request()->getHost(), $centralDomains)) { + return Inertia::render('Landlord/Auth/Login'); + } + return Inertia::render('Auth/Login'); } @@ -36,6 +42,11 @@ class LoginController extends Controller if (Auth::attempt($credentials, $request->boolean('remember'))) { $request->session()->regenerate(); + $centralDomains = config('tenancy.central_domains', []); + if (in_array($request->getHost(), $centralDomains)) { + return redirect()->intended(route('landlord.dashboard')); + } + return redirect()->intended(route('dashboard')); } diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index f6ecd02..4636605 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -14,6 +14,12 @@ class DashboardController extends Controller { public function index() { + $centralDomains = config('tenancy.central_domains', []); + + if (in_array(request()->getHost(), $centralDomains)) { + return redirect()->route('landlord.dashboard'); + } + $stats = [ 'productsCount' => Product::count(), 'vendorsCount' => Vendor::count(), diff --git a/resources/js/Pages/Landlord/Auth/Login.tsx b/resources/js/Pages/Landlord/Auth/Login.tsx new file mode 100644 index 0000000..6d12337 --- /dev/null +++ b/resources/js/Pages/Landlord/Auth/Login.tsx @@ -0,0 +1,101 @@ +import { Head, useForm } from "@inertiajs/react"; +import { FormEventHandler, useEffect } from "react"; +import { Button } from "@/Components/ui/button"; +import { Input } from "@/Components/ui/input"; +import { Label } from "@/Components/ui/label"; +import InputError from "@/Components/InputError"; + +export default function LandlordLogin() { + const { data, setData, post, processing, errors, reset } = useForm({ + username: "", + password: "", + remember: false, + }); + + useEffect(() => { + return () => { + reset("password"); + }; + }, []); + + const submit: FormEventHandler = (e) => { + e.preventDefault(); + post(route("login"), { + onFinish: () => reset("password"), + }); + }; + + return ( +
+ + + {/* 深色背景裝飾 */} +
+
+ +
+
+ {/* 使用不同風格的 Logo 或純文字 */} +
Koori ERP
+
Central Administration
+
+ +
+
+
+ + setData("username", e.target.value)} + required + autoFocus + placeholder="Admin Username" + /> + +
+ +
+ + setData("password", e.target.value)} + required + placeholder="••••••••" + /> + +
+ +
+ +
+ + +
+
+ +

+ SECURE SYSTEM ACCESS RESTRICTED +

+
+
+ ); +}