diff --git a/app.zip b/app.zip
new file mode 100644
index 0000000..71f36ed
Binary files /dev/null and b/app.zip differ
diff --git a/frontend/src/app/admin/login/page.tsx b/frontend/src/app/admin/login/page.tsx
new file mode 100644
index 0000000..34e16bf
--- /dev/null
+++ b/frontend/src/app/admin/login/page.tsx
@@ -0,0 +1,61 @@
+'use client';
+import { useState } from 'react';
+import { useRouter } from 'next/navigation';
+
+export default function AdminLogin() {
+ const [username, setUsername] = useState('');
+ const [password, setPassword] = useState('');
+ const router = useRouter();
+
+ const handleLogin = (e: React.FormEvent) => {
+ e.preventDefault();
+ // Basic mock authentication
+ if (username && password) {
+ document.cookie = "auth_token=admin_token; path=/; max-age=3600";
+ router.push('/');
+ router.refresh();
+ }
+ };
+
+ return (
+
+
+
+
ArmoReg Admin
+
Sign in to central management
+
+
+
+
+
+ );
+}
diff --git a/frontend/src/app/panel/login/page.tsx b/frontend/src/app/panel/login/page.tsx
new file mode 100644
index 0000000..c49ce60
--- /dev/null
+++ b/frontend/src/app/panel/login/page.tsx
@@ -0,0 +1,61 @@
+'use client';
+import { useState } from 'react';
+import { useRouter } from 'next/navigation';
+
+export default function TenantLogin() {
+ const [username, setUsername] = useState('');
+ const [password, setPassword] = useState('');
+ const router = useRouter();
+
+ const handleLogin = (e: React.FormEvent) => {
+ e.preventDefault();
+ // Basic mock authentication
+ if (username && password) {
+ document.cookie = "auth_token=tenant_token; path=/; max-age=3600";
+ router.push('/');
+ router.refresh();
+ }
+ };
+
+ return (
+
+
+
+
Customer Panel
+
Manage your Hotspot & Firewall
+
+
+
+
+
+ );
+}
diff --git a/frontend/src/middleware.ts b/frontend/src/middleware.ts
index 8088e13..dc1727c 100644
--- a/frontend/src/middleware.ts
+++ b/frontend/src/middleware.ts
@@ -3,27 +3,32 @@ import type { NextRequest } from 'next/server';
export const config = {
matcher: [
- /*
- * Match all request paths except for the ones starting with:
- * - api (API routes)
- * - _next/static (static files)
- * - _next/image (image optimization files)
- * - favicon.ico, sitemap.xml, robots.txt (metadata files)
- */
'/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)',
],
};
export function middleware(req: NextRequest) {
const url = req.nextUrl;
-
- // Get hostname (e.g., admin.armoreg.com, panel.armoreg.com, localhost:3000)
const hostname = req.headers.get('host') || '';
// Determine which subdomain we are on
const isAdmin = hostname.includes('admin.armoreg.com') || hostname.startsWith('admin.localhost');
const isPanel = hostname.includes('panel.armoreg.com') || hostname.startsWith('panel.localhost');
+ // Simple authentication check via cookie (to be expanded later)
+ const isAuthenticated = req.cookies.has('auth_token');
+ const isLoginPage = url.pathname === '/login';
+
+ // If not authenticated and not on login page, redirect to login
+ if (!isAuthenticated && !isLoginPage) {
+ return NextResponse.redirect(new URL('/login', req.url));
+ }
+
+ // If authenticated and on login page, redirect to root
+ if (isAuthenticated && isLoginPage) {
+ return NextResponse.redirect(new URL('/', req.url));
+ }
+
// Rewrite to the appropriate folder inside /app
if (isAdmin) {
return NextResponse.rewrite(new URL(`/admin${url.pathname}`, req.url));
@@ -33,6 +38,5 @@ export function middleware(req: NextRequest) {
return NextResponse.rewrite(new URL(`/panel${url.pathname}`, req.url));
}
- // Default fallback (e.g. main landing page or redirect to panel)
return NextResponse.next();
}