I'm just starting with Titanium Mobile and I'm having a hard time trying to get the correct structure to handle a Login and Logout mechanism.
A user may enter into the application in three different states.
- Logged out and no active 'session'
In this case the user should see the the Login screen and successfully login and then set a 'session' pin before being allowed access to data on the device.
- Logged in but with an expired 'session'
In this case the user should see a enter pin screen and successfully enter the sessions pin before being allowed access to the data on the device.
- Logged in with an active 'session'
In this case the user the user will be into the application.
Playing around with the kitchen sink app everything drills down from the window created in app.js and then comes back to it. It's almost like I need to use the tabGroup but without tab buttons to be able to jump around to the various parts of the app.
It doesn't seem right that the Login window would have the main application as a child window or that it would chain to the pin screen which would chain to the main app. I don't want the user to go back to the login screen. They should be allowed to get back to the pin screen or some facsimile to choose a new pin if they like.
In what way do I go about creating this?
Here's the basic gist of how I handle it, and hopefully this can help. This is real brief, and I can elaborate on more specific points/code if you want:
In app.js I have two tabGroups – a Login group and a Main group, each with their own windows. App.js checks to see if the session exists (Ti.App.Properties), and if it does, it opens the Main tabGroup. If it doesn't (or if the session datetime or whatever you're storing is too old), it loads the Login tabGroup.
Once the user logs in, if the Login group was called, it closes that out and opens the Main group.
A modal window with the login page would did the trick too I think.