I am currently working on an application using Angular 6, and I have encountered a scenario with two URLs.
The first URL (url 1) is , while the second URL (url 2) is .
In this setup, users who are logged in via url 1 should only be able to redirect to url 2.
However, if a user directly enters the URL , they should be redirected to for the login process.
To handle this logic, I am using the following code snippet:
if (localStorage.getItem("isLoggedIn") === "true") {
return true;
} else {
window.location.href = "authentication.hello.com";
}
Additionally, I have included:
window.location.href = "authentication.hello.com";
to ensure redirection to the authentication page if the user is not logged in.
One issue I am facing is that when a user directly accesses , the URL displays as . Instead, I want it to remove and display only where the user can see the login screen.
Even when using
window.location.replace("authentication.hello.com")
, I face the same issue of displaying . My goal is to solely load the URL authentication.hello.com
without including application.hello.com
if the user is not logged in.
If anyone can assist me in achieving this behavior using pure JavaScript or TypeScript, I would greatly appreciate it.