In my {N}-App, I am looking to create a login system for users. After a successful login, the user receives a token required for making requests. Currently, I store this token using the application-settings
module. Now, I want the UI to dynamically switch between the "Login Screen" and "Personal Information" screens based on the user's login status. The features of the application are accessible even without logging in, positioning the login tab on the sidebar.
I believe the route needs to be redirected to another component or the component overlay should change depending on whether the user token is saved. Is there a way to achieve this? I assume certain configurations need to be made in the component annotation within the .ts file, which may require modification of the routing setup.
I realize that there is some redundancy in defining the tab name both in the Route and the routing directory, indicating a need for routing adjustments regardless.
One idea I had was:
//router definition
path: "Main", component: MainPage, children: [
(appSettings.getBoolean("isLoggedIn") == true) ?
{path: "Login", component: LoginPage} :
{path: "My Account", component: LoginPage}
]
Unfortunately, this solution did not work as expected. Are there any other suggestions?
Edit:
Perhaps I haven't articulated my challenge clearly. My application features a sidebar with a "Login" label. When a user clicks on it and logs in, I want the "Login" label to be replaced with an "Account" link where the user can view personal information. This account access does not grant permission to new pages, so the objective is to simply swap the sidebar entry and page overlay accordingly.