• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.


Designing login functionality

Page history last edited by Lee Barney 11 years, 5 months ago

Recently I recieved a request for information about how to use QuickConnectiPhone to do some type of login of the user to the application.  I am including some of the information here on the wiki incase anyone else needs it.  It also shows how to design the handling of commands using a flow 

diagram seen here.




My response to the email is as follows:
Here are the assumptions that I am getting from reading your email.
1.  You want to create a stand-alone, installable application for the iPhone written in HTML, CSS, and JavaScript.
2.  You want to password protect all or part of the application.
3.  You have not used the Stack Layout pre-built component in Dashcode previously.
4.  You are new to QuickConnectiPhone.
5.  You are not presenting a login page for data retrieval from a server somewhere on the Net or a network.
If any of these assumptions are incorrect please let me know because the following advice is based on these assumptions.
The Stack Layout Dashcode component allows you to create any number of views within a single HTML page.  You use these views to display any visual content you desire.  In your case one of these views could include a field or fields for logging in.  The Stack Layout component also allows you to define transition types such as push, slide, dissolve, fade, flip, cube, swap, and revolve as well as the timing of the transition.  This is much more user friendly than loading a separate page since the user truly feels that they are still in the same application.  A nice side benefit for you as a developer/engineer is that variables you set in your JavaScript are still set as the user navigates your application.  You don't have to use server-side storage and/or cookies to transfer information between user pages.
I am of the opinion that installed applications with stand-alone secure data may not need a login since the iPhone has a simple security password system at the operating system level.  If the secure data is on a server somewhere then of course a login is needed.
If I was going to create a login for secure remote data using the QuickConnect library there are a few things I would do after looking at the HistoryExample and PictureExample Dashcode examples in the 1.1.3 download.
  1. I would create and map a Validation Control Function (ValCF) to make sure that the field or fields contained the correct types and sizes of information required for logging in.  There aren't any current examples of this in the download.  Is one needed?
  2. Create and map a Business Control Function (BCF) that checks performs the actual logging in.  If the data is remote this would include using the ServerAccessObject to do my AJAX call for me.
  3. Create and map another BCF to evaluate if the login attempt was successful and set a global flag to true if it was (window.loggedin = true).
  4. Create a View Control Function that in the case of a successful login would move the user to the view that allows user access to the secure portions of the application.
  5. I would use the command 'login' for all of these control function mappings.
  6. I would also create and map an ErrorControlFunction (ECF) to a 'failedLogin' command.  This I would use in the code for the BCF in number 3 if the attempted login failed by calling 'dispatchToECF('failedLogin') and would display a textual element on the screen helping the user understand what has happened.  As you know this element usually says something like 'Incorrect user name or password.
I have attached an image that shows how I design the handling of all commands in my applications.  It is called LoginFlowDesignDoc.png.  It shows the flow of computation that results from calling 'handleRequest('login')' and the possible branching for error handling.  I have found that if I layout the flow like this then the creation of the mappings and control functions becomes very easy.
Remember that the ServerAccessObject's AJAX call will be asynchronous and that any BCF's and VCF's in the flow after the BCF using the ServerAccessObject are executed by the framework after the result is returned from the server.
Here is another thing that may be different than what you may be used to.  I never return HTML or other display code from my servers.  I always return JSON strings that contain only data, no JavaScript.  I then use the data within the views I have already created at design time for my application.
Here is some background on the control function types you can use with the framework.
Validation Control Function (ValCF) - used to validate types, sizes, and content of user input.
Business Control Function (BCF) - used to access, manipuate, and store data from an to databases, servers, and JavaScript variables.
View Control Function (VCF) - used to update the screen or viewable components
Error Control Function (ECF) - used to handle error conditions
Security Control Function(SCF) - used to ensure the security of data retrieved from remote sources such as servers.
For a quick introduction on using the framework check out this article:  Using QuickConnectiPhone.


Comments (0)

You don't have permission to comment on this page.