修改注册登录界面,新增路由保护

Change-Id: I6c665d9e92813506158113fe97c1119d7ad09d92
diff --git a/front/src/RequireAuth.js b/front/src/RequireAuth.js
new file mode 100644
index 0000000..77cde56
--- /dev/null
+++ b/front/src/RequireAuth.js
@@ -0,0 +1,17 @@
+import React from 'react';
+import { Navigate, Outlet } from 'react-router-dom';
+
+// Component to protect routes that require authentication
+const RequireAuth = () => {
+  // Check if userId cookie exists
+  const getCookie = (name) => {
+    const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
+    return match ? match[2] : null;
+  };
+
+  const userId = getCookie('userId');
+  // If not authenticated, redirect to login
+  return userId ? <Outlet /> : <Navigate to="/login" replace />;
+};
+
+export default RequireAuth;