JSF Faces Flow: reset flow when entering same flow again - jsf

My Faces Flow has several nodes and it starts when a user enters the first node and finishes after the exit node is called. So far so good...
In my application a user has, at any point in the flow, the chance to navigate to another page via a menue.
If this happens and the user again enters the flow, I want to start a new flow.
However, the old flow is still active, because it has never ended properly.
Is there a way to achive this behaviour and always start a new flow (and end the old one) if a user enters the first node again?

Related

Best practice to check if the user is logged in during the entire session

I'm using React on the front, nodejs + express for the back, mongodb , and passportJS for the auth, and express sessions to store the session information.
Whenever someone joins my website, react is sending a request to the backend to check if the user is logged in, and then if the user is logged in it will show adapted content. The problem is that whenever someone is logged in it will first show in the nav bar a button that says "log in" and only half a second later will it be updated to "log out" because the post request that says the user is logged will resolve. What is the best practice to solve this issue? at the moment I check if the user is logged in every single time that the user navigates to a new page and it does not sound like a best practice to me.
Try adding a loading state to your component. So instead of two states of login and logout, you will have login, loading, and logout.
This will allow you to add a new UI state for loading. Now it up to you to decide the UX.
UX Solution:
Some sites just put a giant loader and blocks the site till the app is loaded which works but is not that appealing.
A more modern solution is to use a skeleton loader. This will display a fake component while the application is loading (Note: NOT the whole sight needs to be in this skeleton state. It can be only the navbar while the rest of the application is displayed).
See AntD skeleton: https://ant.design/components/skeleton/

Azure Active Directory B2C navigation failures using Xamarin Forms

using the built in sign-up and sign-in policy with azure AD, the user can signup and the account gets created, but the UI never returns back to the app. It stays here
The same issue happens when testing the user flow in the azure portal.
I'm not sure what to do or where to go from here on testing this?
There are other little funny quirks that I notice also. When the cancel button is clicked the UI never redirects back to the sign in page. the loading progress bar moves across as if something should be happening but it never goes back to the previous page.
Same thing when trying to go forgot password page.
EDIT
here is a repo https://github.com/champcbg/AzureAdB2CTest with azure ad credentials stripped out that follows these instructions https://learn.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/authentication/azure-ad-b2c the sign in and sign up work successfully i can see the results in azure, but the hand off never is given back to the android app.
the code in the green block is executed and that is how the sign-in and sign-up pages are shown. after either action the code never comes back to line 79 (red arrow).
but if the back button (on the phone) is pressed control is given back to the app, the code falls into the exception block as a "authentication_canceled" event.
Finally got it working. I was never able to solve the issue of the app coming back from the await. I am leaning toward the error being that the active page was never not found again. that is only an assumption that can not be confirmed.
https://github.com/Azure-Samples/active-directory-b2c-xamarin-native
Following the code example for the project link above solved the problem. The key differences from the original example are
Authentication was extracted to a service not bound to button clicks, which was actually my desired path anyway or in view models.
Parent Window locator service which is used in the android project
The complete solution was built by following these instructions https://learn.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/authentication/azure-ad-b2c for creating the Azure AD resources and this for actually implementing the xamarin app https://github.com/Azure-Samples/active-directory-b2c-xamarin-native

Serverside Xpages application update causes my browser page partial refresh actions stop working - how to detect it?

Any Xpages application update in design causes the application refresh which removes scope variables, session etc. When this occures and there is a page opened in users browser with some partial refresh action buttons ... such buttons simply do nothing when clicked which is quite confusing. No message that's warning the user that the page is stale or something. Is there a way how to detect such situation in general so I can inform user in browser with some dialog that he should reload the entire page?
For all scope variables above request (which gets initialized when you send a request and is always shiny and new) you never can take their existence for granted. Best example: user leaves a form open, locks the PC, goes for lunch, lets the session expire (which also deletes the view scope). (S)he comes back, opens a new tab and logs in - so there is a valid (new) session, hits submit in the first tab -> bum all your code fails.
This is the same scenario as an updated design short of the scenario Panu was pointing to.
So in your code check for the existence of your scoped variables and force a full refresh. Or (I like that better) add an error to the page so that gets displayed with an appropriate action.

Visual Studio Web Test - Do not Repeat Login Step

I have created a simple web test in Visual Studio to be used in a load test. This web test logs in to a site using forms authentication, then takes some other actions after logging in.
The issue I am having is that when this web test repeats, the log-in step is performed again. I tried adding a conditional to only log-in if the .ASPAUTH cookie does not exist, however it seems that cookies are cleared/a new session is started each time the web test is repeated.
Is there a way to configure a web test so that the log-in step only happens once, but all subsequent steps are repeated until the conclusion of the load test?
This may not be the best way, but the way I eventually solved this problem was to add a loop that included all requests after the initial Log-In requests. The loop condition checks for the existence of the '.ASPAUTH' cookie, which is set once a user successfully logs in. Therefore the user will log in, hit the loop, and continue repeating the loop (unless a request within the loop causes the user to log-out).

Response.Redirect not firing due to code to prevent re-submission

I have an event which needs to contact some third party providers before performing a redirect (think 'final payment page on ecommerce site') and hence has some lag associated with its processing. It is very important that these third party providers are not contacted more than once, and sometimes impatient users may try and refresh the page (hence re-submitting the data). The general code structure is:
If Session("orderStatus") <> 'processing' Then
Session("orderStatus") = 'processing'
DoThirdPartyStuffThatTakesSomeTime()
Response.Redirect("confirmationPage.asp", True)
End If
The problem is, if the user refreshes the page, the response.redirect does not happen (even though the rest of the code will run before the redirect from the original submission). It seems that the new submission creates a new thread for the browser which takes precedence - it skips this bit of code obviously to prevent the third party providers being contacted a second time, and since there is no redirect, just comes back to the same page. The whole second submission may have completed before the first submission has finished its job.
Any help on how I can still ignore all of the subsequent submissions of the page, but still make the redirect work...?
Thanks
Move you redirect out of the if structure:
If Session("orderStatus") <> 'processing' Then
Session("orderStatus") = 'processing'
DoThirdPartyStuffThatTakesSomeTime()
End If
Response.Redirect("confirmationPage.asp", True)
After a bit more research and investigation (including alot of tracing and tracking what was firing and when using session variables) I found that ASP.NET automatically serialises requests for a given session, so that each one will execute in turn. However (and this is what confused me), the 'Response' delivered to the browser is the result of the last action performed (assuming this action was initiated before the browser received a response to the previous action). So, in my case above, all the third party code initiated by the first request finishes execution before the second request even starts. When all the requests are finished processing, ASP.NET obviously delivers the HTML back from the last request to IIS (which happened to be just a refresh of the page).
So, Oded's first suggestion above about moving out the redirect was correct - and I've marked this with the answer.

Resources