♻️ refactor(auth): move the auth component to the auth.js file in the helpers folder

This commit is contained in:
Apple\Apple
2025-06-04 00:21:03 +08:00
parent 5a22f33bcf
commit d27981bd34
4 changed files with 26 additions and 31 deletions

View File

@@ -1,14 +0,0 @@
import React from 'react';
import { Navigate } from 'react-router-dom';
const AuthRedirect = ({ children }) => {
const user = localStorage.getItem('user');
if (user) {
return <Navigate to="/console" replace />;
}
return children;
};
export default AuthRedirect;

View File

@@ -1,12 +0,0 @@
import { Navigate } from 'react-router-dom';
import { history } from '../helpers';
function PrivateRoute({ children }) {
if (!localStorage.getItem('user')) {
return <Navigate to='/login' state={{ from: history.location }} />;
}
return children;
}
export { PrivateRoute };