- This topic has 9 replies, 2 voices, and was last updated 10 years, 10 months ago by
Code_A.
-
AuthorPosts
-
SOUPSMemberI know this question has been asked and I have honestly searched and looked at all the examples but they really don’t make any sense to me.
I am working with Mobione 2.6.2.
I want to have a simple login screen at the start of the app. Username and Password with a login button.
Is it possible to have it call from a table that I have uploaded to my website file manager?
If so, can anyone put it in the easiest terms to do it?
What code I need for Mobione and how to setup the table that I upload to the website…
Thanks a lot, my head is literally smoking over here!
Code_AMemberThis post may be helpful to you viewtopic.php?f=8&t=7157. It explains the necessary steps to establish communication between the app and your DB..
There is also some example AJAX code in this post too viewtopic.php?f=8&t=7216.
There is also a login example in the how -to section that used a form to submit the data.
The m1 implementation is quick and easy IF you have the web service setup on the server. I use PHP CodeIgniter to setup mine.
SOUPSMemberThank you for the reply…
I have looked at those examples and have found one that I like but other than linking my app to the “Login” button, I don’t know how to make it authenticate to my server… there really aren’t any step by step directions in any of the examples that make any sense to me.
Code_AMemberThe authentication happens on the server side, usually through PHP or ASP web service. M1 only deals with the client side of the communication.
I use CodeIgniter (PHP framework) to setup my web service. Here is a tutorial for Working with RESTful Services in CodeIgniter. If you do not want to use CodeIgniter, then a Google search will turn up a tutorial in your preferred language.
You need to setup this service to pass the data back and forth to your database. Your M1 app cannot directly access the database on your server, it does it through the web service.
SOUPSMemberThanks again. I’m not sure our website has this option without paying the company more to add it on…
Is there a way to do it simply with html and have ONE login/password for all users? Something just built into the app itself?
Thanks again!
Code_AMemberMaybe this post will help?Password Protect App. Keep in mind this method stores the info locally.
I am sure there is way to do it through a file on your server, but this is probably not the most secure method like having a database with a web service front end.
SOUPSMemberI contacted the admin of our website we use for our company and they said I can set up the app to use their website for user/pass verification using the following:
Can anyone tell me where exactly I need to put this information?
To verify a login:
Send request to http://www.*******.com/app/verify.cfm
You must send appuser and apppass to the script as the variables that contain the username and password entered by the user. If the login combination is valid the following XML will be returned.
<?xml version=”1.0″ encoding=”UTF-8″?>
<root>
<VERIFY accessgranted=”TRUE”/>
</root>If the request is not a valid combination the following XML will be returned.
<?xml version=”1.0″ encoding=”UTF-8″?>
<root>
<VERIFY accessgranted=”FALSE”/>
</root>To start a login session with the website:
Send request to any url of the website. Include the same appuser and apppass variables with the users entered values. Also include an extra variable named action and set the value of the action variable to applogin and that will initiate a session in the website if the login is a match. The content of the url would be returned. If not a match they would be redirected to the login page of the website.
Code_AMemberYou will need to pass the username and password through an AJAX call and then the web server will return the pass/fail status in XML format.
Take a look at this post, maybe it will help get you started: viewtopic.php?f=8&t=7216
You may also want to google AJAX and research it if you are unfamiliar with how it works. Here is the jQuery AJAX Documentation
Your AJAX code goes in your <screen>_custom.js file in your app’s project folder.
SOUPSMemberThanks again for the reply but I am completely lost.
I have designed the entire app but I think this login portion is just beyond my understanding.
I will have to find someone to assist me further.
Thanks for your time.
Code_AMemberHere is an example from an app I have, but mine returns in json format instead of xml. Just change the “json” to “xml” and process the return data accordingly.
This code (simplified version shown) is in my <screen>_cusom.js file (this code is not tested an assumes you have a submit button and 2 fields for username and password. It also uses the POST method of data transfer to the server):
function doLogin(){ var username = $('#m1-<screen>-txtUsername').val(); var password = $('#m1-<screen>-txtPassword').val(); //send login inormation var url = "http://www.*******.com/app/verify.cfm"; //this your company's authentication server var send = JSON.parse('{"username" : "'+ username +'", "password" : "'+ password +'"}'); //these are the variables that you pass to the web server for authentication. The names are specific to your company's web service. var response = sendRequest(url, "POST", "json","application/x-www-form-urlencoded; charset=UTF-8", false, send ); alert(response); //this is the data string that is returned from the server alert(JSON.stringify(response.loginstatus)); //this is how the direct json variable is accessed, in your case this will be the xml node //proceed if login is successful if (response.accessgranted){ //login successful }else{ //login failed } } //this is where the AJAX call is made and processed function sendRequest(cmd, method, data, content, sync, send){ if (send){ //post data var webReq = jQuery.ajax({url: cmd,type: method,dataType : data,contentType : content, async : sync, data : send}); }else{ var webReq = jQuery.ajax({url: cmd,type: method,dataType : data,contentType : content, async : sync}); } webReq.done(function( webText, status, jqXHR ) { // Process incoming data here response = webText; return; }); webReq.fail(function( jqXHR, status, errorThrown ) { response = false; return; }); webReq.always(function( jqXHR, status, errorThrown ) { return; }); return response; }
Place the following code behind your button:
doLogin();
Hope this helps get you started.
-
AuthorPosts