tom1sl
tom1sl
SSolidJS
Created by tom1sl on 3/26/2024 in #support
Handling of sensitive information from the front end
Hello, I am new in front end, now I am trying to make some components, that are shown/hidden depending on the role of the user, if it is admin I want them to see the button and the administration component that is rendered when clicking, but I am thinking that if I save the role in localstorage and a user changes the role of member by admin, he could see the button, then the component could not, because it makes a get request to the backend and this if it verifies in a jwt that is not admin, but meanwhile he can see this part of admin without being admin. I was implementing cookies http only for the request, I'm still in that, and I entered that doubt, how could I protect and pass information to the backen decoded, without the user can modify it, if someone would have the patience to explain how to handle this, if it is only by local or session storage, or there is a more secure way, I will be very grateful, thank you very much.
3 replies
SSolidJS
Created by tom1sl on 2/24/2024 in #support
Import error with Outlet
This is the code I apply to my routes to protect them from users who are not logged in, and I get this error in the browser console, I don't understand why I get this error if I followed the documentation.
import { Outlet, useNavigate } from "@solidjs/router";

export default function ProtectedRoute({
canActivate,
redirectPath = "/auth/login",
}) {
const navigate = useNavigate();
if (!canActivate) {
navigate(redirectPath, { replace: true });
return null;
}

return <Outlet />;
}
import { Outlet, useNavigate } from "@solidjs/router";

export default function ProtectedRoute({
canActivate,
redirectPath = "/auth/login",
}) {
const navigate = useNavigate();
if (!canActivate) {
navigate(redirectPath, { replace: true });
return null;
}

return <Outlet />;
}

Uncaught SyntaxError: The requested module '/_build/node_modules/@solidjs/router/dist/index.jsx' does not provide an export named 'Outlet' (at CheckAuth.jsx:1:10)
Uncaught SyntaxError: The requested module '/_build/node_modules/@solidjs/router/dist/index.jsx' does not provide an export named 'Outlet' (at CheckAuth.jsx:1:10)

This is mi app.jsx
export default function App() {
return (
<Router
root={(props) => (
<>
<div>
<Suspense>{props.children}</Suspense>
</div>
</>
)}
>
<Route element={<ProtectedRoute canActivate={true}/>}>
<FileRoutes path="/" element={<Home />} />
</Route>
<FileRoutes path="/auth/login" element={<Login />} />
</Router>
);
}
export default function App() {
return (
<Router
root={(props) => (
<>
<div>
<Suspense>{props.children}</Suspense>
</div>
</>
)}
>
<Route element={<ProtectedRoute canActivate={true}/>}>
<FileRoutes path="/" element={<Home />} />
</Route>
<FileRoutes path="/auth/login" element={<Login />} />
</Router>
);
}
7 replies