Redirect to login page on commandButton press if session is invalid - jsf

Brief: How can i redirect to the login page when commandButton is pressed and the user is not logged in anymore?
In detail:
I am trying to solve the following scenario in my primefaces application:
I successfully log in in my web application
I open a new tab while logged in.
Now i log out from the second tab that i opened on step 2. In this tab i get redirected to the login page
Press a commandButton from the 1st tab that still looks like if the
user logged in but not many things happen .
When trying to access a page through a link while logged out, then yes i am redirected to the login page. The same does not happen though with the commandButton component.
I am using a filter already and tried to catch that case, meaning to confirm if on button press the session is null to redirect me to login page.
As seen here: https://stackoverflow.com/a/1027592/1918516
The problem is that even though i logged out from the 2nd tab, and press a button from the 1st tab, my session is never null.
Update: After logging out and invalidate the session with invalidateSession() i see that my session is null. But when press on a button from the first tab, the session is NOT null. Could this be that the browsers cache is somehow maintaining an invalid session ?
Also i want to note here that i am retrieving the session with request.getSession(false)

Related

Browser back button is not working in Blazor web-server

I want to go previous page when the user clicks on the browser back button. When I navigate another page, I can not go to the last page by using the browser back button. So, can anyone help me find a solution to this problem?
Ensure that every state that you want to show up in next/back is differentiated by a route change navigated to by NavigationManager.
If you make a page /somePage and you let the user step through several choices, and then the user navigates (using the URL bar) then hits the back button on the browser, they will go back to /somePage and not back to the choices they made.
If you make a page /somePage and each time the user makes a choice they are navigated to a new page using NavigationManager, for example /somePage/someSelection, then when they hit back they will go back to /somePage/someSelection. This requires you to load data on subpage choices on init based on optional page route parameters, but the tradeoff is having browser navigations that are part of next/back.

Logout all tabs and if you logout in one tab it needs to be logged out automatically in all other tabs

We are opening Gmail in two tabs and if you logout in one tab it needs to be logged out automatically in all other tabs
It gets automatically logged out from the other tabs as well if you logout in one tab. If you're NOT getting logged out, try refreshing the page.

Facebook 'Continue' button misplaced in Chrome Extension oauth popup

I'm using chrome.identity.launchWebAuthFlow to start the login flow and when the user oauths with Facebook, the bottom 'Continue' button is partially out of the view. When the user has to enter an email and password for the first time, it's fine, but when Facebook asks only for the password the next time, the issue occurs. Also on the 'Forgotten you password?' page.
Since chrome.identity.launchWebAuthFlow doesn't allow to set size, and resizing the window manually moves the button, but at the same misplaced position, I see it as a clear sign that it's Facebook's code or the chrome.identity.launchWebAuthFlow's window's quirk.
When opening up the same auth url in a real browser window, the button is placed at the right place.
Anyone else came across this issue? Is there any good workaround?

Chrome extension: show browser action popup only in some cases

I have a chrome extension. When the user clicks the icon I want to:
Check if the user is logged in. This uses google storage (I've got this code already).
If user is logged in, there should NOT be a popup.
If user is not logged in, show browser action pop-up with login post/ajax form.
Google says "If a browser action has a popup, the popup appears when the user clicks the icon." https://developer.chrome.com/extensions/browserAction.html
So I guess not? I could instead add a form to the page DOM, but I'd rather not do that. Any other nice solutions?
Use chrome.browserAction.setPopup({ popup: ''}) to remove the popup.
From the browserAction.setPopup docs:
Sets the html document to be opened as a popup when the user clicks on the browser action's icon...
popup ( string ): If set to the empty string (''), no popup is shown.
You can use chrome.browserAction.setPopup to specify a popup page to show, or no popup at all. However, you must specify the popup before the user clicks the browser action; I don't believe you can change it "just in time" as the user clicks. You should simply start with the popup active by default, and then turn it off once the user has successfully logged in.

Browser back button navigation

Whenever browser back is clicked, it must not navigate to the previous page but to some default page. how is it done using JSF ?
Clicking on browser back button requests the result page from the browser cache.
This is a client side activity. It doesn't send request to your server for fetching some default page(in your case).
Please refer this post for writing a filter indicating the browser not to cache dynamic JSF pages.
And also you can refer this one for more details.
You can try to detect if User has clicked on browser back button by writing client side code.
Refer this post for detecting back button click.
If you are trying to alter the behaviour of browser back button, it indicates some kind of flaw in your application.

Resources