Set GetUserId() Value So Mobile App Can Do Login Offline

Set GetUserId() Value So Mobile App Can Do Login Offline

  

Hi,

I have a need that the application can be accessed via offline mode, with the username and password that already stored from previous online login. 

But because the next screen has "registered" attribute and GetUserId() = nullidentfiier(), it keep redirected back to login screen.

Question :

How can I set the getuserid() value in client action ?

Thanks in advance.


Hi tBt,

By default you should've stayed logged in... what are you using to test your application? the web browser Device Simulator, OutSystems Now on the device, or a Native App?

Hi Jorge,

Sorry I didn't explain the detail.

Here is the case.

1. User login to app online. When this happen, I have action that store the username and password in local table.

2. User logout.

3. Tomorrow, user want to login again, but the network is dead. I can authenticate about username and password, but because the next screen has "registered" attribute and GetUserId() = nullidentfiier(), it keep redirected back to login screen.


Solution

Hi tBt,

I understand how that behaviour might seem interesting, but:

  • storing username/password in local storage is definitely not secure;
  • even if you stored the user credentials in some secure place (there are plugins for using the devices KeyChain and also encrypted storage), it still isn't a common usage pattern for end-users... logging-in is naturally an online process... if you've logged out, it is expected to require network connectivity to log in again (there is more than authentication to Login, there's also roles that are assigned to a user that also need to be taken into account, for instance).
  • Finally, as far as I am aware, there is no way of programmatically set the authenticated user on a client action, so even if you store the user credentials and check against them manually, it will not be possible to use the platform roles to authorise him/her on screens...
Solution

Hi Jorge,

Ic, ok then tq for the explanation.

Jorge Martins wrote:

Hi tBt,

I understand how that behaviour might seem interesting, but:

  • storing username/password in local storage is definitely not secure;
  • even if you stored the user credentials in some secure place (there are plugins for using the devices KeyChain and also encrypted storage), it still isn't a common usage pattern for end-users... logging-in is naturally an online process... if you've logged out, it is expected to require network connectivity to log in again (there is more than authentication to Login, there's also roles that are assigned to a user that also need to be taken into account, for instance).
  • Finally, as far as I am aware, there is no way of programmatically set the authenticated user on a client action, so even if you store the user credentials and check against them manually, it will not be possible to use the platform roles to authorise him/her on screens...

From your explanation what is the use of having offline apps if I need to be online to navigate between screens?


Hi Leo,

You do not need to be online for navigation, unless your screens need it (e.g. need to call a webservice for retrieving data).

You can navigate offline without any restriction (actually, you always navigate "offline", while you're Splash screen is displaying, the application's static resources and screen definitions are being downloaded), but in order to login you need to check the user credentials against what's stored in the Database... and *that* has to be done online (the same for any other database data you may require).