6
Views
4
Comments
Solved
[MSAL Plugin] Persisting login session
Question
Forge component by Walter Robins
2
Published on 11 Feb 2021
Application Type
Mobile

Hi,


can I check if we can persist the AD login session, so that user no need to sign in again subsequently?


Is is possible to go directly into the app with selecting the login account again?


thank you.


appreciate.


cheers

Darryl

Rank: #5424
Solution
Rank: #5424

Hi Darryl,

If I understand your question, this is definitely possible. To achieve this behavior, put an OnInitialize on your home screen and try to sign in the user silently, and then call a DoLogin server action that simply logs in the user with no password (because we already handled authentication with MSAL, so OutSystems isn't aware of any password) if you get an account back, and then continue loading the home screen. If there's an error or no account comes back, then call SignInInteractive, like this:

If you're doing a multiple account setup, then you can do something a little different and call GetAccounts after MsalInit and see if anything comes back. If only one account comes back, then do the SignInSilent flow just like the screenshot above ^ and pass in the account id to SignInSilent. If multiple accounts come back, then you can take them to a screen with a list of all the accounts. They can pick from one of those and, depending on your particular security requirements, either sign in that account silently, or interactively by default.

I hope I've answered your question, but if not, please don't hesitate to ask follow-ups!

Rank: #32279

Thanks Walter.


I will try out your recommendation. Hopefully it works.


Appreciate so much.


Cheers

Darryl Ng

Rank: #32279

Thanks Walter for your recommendation.


It works.


Appreciate.

Rank: #5424
Solution