suppose I am on the home page or any page of application if I want to open any page like google from the same tab then i will remove current URL and type google.com then it will go to google page and if i click on browser back button
it will not go to home page of my application which is already login so it should go to the login page of my application in angular js
On your login page you should check if the user is already logged in. If the user is already logged in, redirect the user to where you want them to be.
An other option is to check before changing routes. If the user is logged in and wants to go to the login page, you can deny that route change. (check $routeChangeStart in the angular $route documentation)
Related
I'm working on a Nuxt JS project, and I want to automatically redirect inactive user after a period of time (10mn) to home page of the app, and if the user is already on the home page, the page will be automatically refreshed.
Knowing that I have already a middleware to redirect user to the login page when access token expired.
I am developing a webpage using HTML, CSS & JS. In a section with a list of links, when a user clicks on any of the items in the list I want the user to first have to sign in before they continue on the path of the item they selected and I want to do this without having to duplicate a sign-in page for each stage. I want the link to first go to the login page(login.html) then continue or go back to the path it was on
the problem now is I don't know how exactly I can achieve this without creating multiple copies of the login page
You must persist user state somewhere, either in browser (not safe at all) or on server.
In server: Save information to cookie/session
In browser: Save information to session/local storage
On every protected page visit check if user has been authorized by checking previously set flag. If it's not authorized, then redirect to login page. After successful authorization redirect back to requested protected page.
I currently have a page that is protected by a group that requires a login. the protected page has a redirect to a login page if the user is not logged in. How do I redirect the user back to the correct page if login is successful? currently I have it hard coded to the url in case the user accesses the login page directly. I was thinking of using history.go(-1); but if the user access the login directly after visiting a random website wouldn't that user just get directed to the wrong site?
I am working in angular js, When a user logged out from the browser and click browser back button (or) user Bookmark URL and load after logout.
will load the controller page and check session exists, If not redirect to login page.
which will take 5 seconds time and display UI of the previous page after logout?
Please give me a solution How to solve this issue
sorry if I ask a basic question, please give me a clear explanation friends
I didn't have any friends working on angular js
you have to use authGuard service provided by angular2.
where you can control user to load particular template on the basis of condition which is based on your condition i.e login/logout in your case
you can use their default methods like canActivate and canActivateChild
see here
http://blog.thoughtram.io/angular/2016/07/18/guards-in-angular-2.html
https://angular.io/docs/ts/latest/guide/router.html
Because you have to check your logic/condition on routing or we can say before page load so you have to use Guard of angular2 in routing
I have a RoR site that loads a splash page on the first visit. It's simply a page with information about the service and a form to enter credentials. When the user logs in, the form submits to the same page (document root) but if the user is logged in successfully, the actual site is loaded. My issue is that when the user presses the back button, they're taken back to the log in/splash page. This makes sense because the browser has cached the page, but I'd like it if I could somehow tell that the page is being shown from cache and reload it.
You can see the same functionality on facebook.com:
Go to the home page logged out.
Enter your credentials and click log in
Once logged in, press back button to go back to home page.
Page will automatically reload to bring you to your logged in state.
Set a cookie upon login. Have the home page check for the cookie and redirect accordingly.
Send the appropriate headers instructing the browser not to cache that page.