Chrome extension: show browser action popup only in some cases - google-chrome-extension

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.

Related

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?

Using chrome extension open tab and allow auto login

In popup.html, I am having one submit button. Clicking on that button, I want to open url in new tab and pass username-password so that user can auto login to the website.
I don't want to use manifest's background and content_script.
I want to do it in normal popup.js which is included in popup.html. Is there any way to do that?
Thank you,
Trupti

Redirect to login page on commandButton press if session is invalid

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)

Liferay: how to prevent landing pages (login and logout) from being shown in the menu?

I'm trying to find a clean way so that the login and logout pages for my liferay portal aren't shown in my menu. For the login page I guess I could move the user to the private pages section but I have no clue how I can make the logout landing page not visible. And preferably the logout page would only be navigable to when you're effectively logged out so users can't accidentally go to it when they've got the url cached in their browser.
Any input would be appreciated.
Regarding hiding the landing pages: Just create them and check "hidden" in "Manage Page" for that page. This will make the page accessible according to the permissions, but hide it in the navigation - e.g. if you know the page's name, you can go there - just as you requested.
If you display the currently logged in user on the logout landing page (e.g. through the "Sign In" portlet, you don't need to display a message like "you've been logged out", but display the current state of the user's session.
Of course you're free to not use the Sign-In opportunity on that page, in this case you'll have to display the current session state in a different portlet. It could be as simple as a templated WebContent portlet, accessing the currently logged in user.
Edit: If you set default.logout.page.path=/web/guest/logout and auth.forward.by.last.path=true but you're still not redirected on logout, chances are that changes made through the UI override your portal-ext.properties. If you've edited "Settings" in ControlPanel, this is most likely the case. You can set these values there, on the first page in settings.
As noted in your comment: You cannot make the first page hidden. This shouldn't be a problem: Just make any other page hidden. Even if you don't have more public content than this, you can have at least a public page stating that you need to login. Make this the first, so the logout page can be either a child page of this or a new toplevel page - but most importantly: It can be hidden.

Dynamic navigation in JSF

I have a footer link "Privacy Policy" in my application. When user clicks this link we display some information on the page along with a "Back" link.
Now requirement is when user click on the Back link I need to display the previous page from which he had opened Privacy policy page.
For example
User is on page A clicks "Privacy Policy" and then when he clicks "Back" we should display page A agian.
If he clicks "Privacy Policy" from page B then when he clicks "Back" we should display page B.
We can use JavaScript to do this but we are not supposed to use JavaScript. Can anyone help me on this?
You can pass an URL parameter to your "Privacy Policy" link telling what is the current page. Then, you will use it as the outcome of "Back".
Use javascript (history.go(-1)) - JSF uses a great amount of javascript already so don't worry.

Resources