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.
Related
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 have a web applicaiton written in ASP.NET MVC 5. There is to be a landing page in .cshtml. When the user clicks on a button on this page, I am to check whether the user has already logged in (by checking the presence of a specific cookie and its valid value). If the user is already logged in, the landing page should be replaced by the target page. If the user is not logged in yet, a popup window is to be displayed for him to enter his login credentials. If he enters correctly, the login popup window should close, and then the landing page is to be replaced by the target page.
As I don't have prior experience with MVC, I need some help on this. When the user clicks on the button on the landing page, how to send the request to the server to check whether he is already logged in, and only replacing the landing page with the target page if the user is already logged in? Also, if the login popup window is showing, and the user enters a correct credentials, how to replace the landing page with target page?
A simple example would be good.
Thanks in advance.
I am going to attempt to answer this from a higher level instead of provide a generic yet more technical example that is likely going to have to be re-coded to fit your needs.
You will need a boolean variable on your model, lets call it loggedIn. This will represent the logged in state of the user.
You want the controller to check the cookies first
If the cookie reads that they are logged in then assign loggedIn to true
If the cookie reads that they are not logged in then assign loggedIn to false
Once you pass your model to your view, you can then use RAZOR to read the loggedIn boolean. If it is true show the content. If it is false show the partial view for your log in.
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)
I am new to angularJS.
I have a login page. I have made sessions using servlets.
But when user manipulates the url and hits enter then the servlet is getting called asynchronously and backend checks whether session is active or not.
If user is not logged in , then it gives a pop-up saying "You need to login first."
But the problem is that the template corresponding to that url is loaded first and then the pop-up comes.
I want the user to stay on the login page itself and give a popup on the same page even if he/she tries to change url.
Is it possible with angular to call the servlet first and then if "success" then load the view?
Any help would be appreciated.
Thanks in advance.
I have a page tab app that has server-side checks for whether the user is logged in, has given the required permissions and has liked the page. If any of those is not complete, the page contains only the JS required to do what's needed. When everything is done, page is reloaded via location.reload(true), and the server-side checks run again just to be sure, since I need the data on the server-side eventually.
The problem is, for some users, one of which, conveniently, is my colleague, the server-side check for user always fails on these page reloads (both $fb->getUser() is 0 and $fb->api('/me') throws an exception). The data is all there, user is logged in, has given all permissions, has liked the page, everything is correct, but server-side - can't retrieve user, even though the page is being refreshed. However, if I click cancel on the page refresh dialog (Firefox shows it since signed_request is being posted) and manually refresh by clicking F5, everything goes on correctly.
What could cause this and how to fix it?
App: https://www.facebook.com/dateks.lv/app_744983135526926