Login Form

Discussions regarding developing applications using Servoy Mobile (new in Servoy 7)

Login Form

Postby jasantana » Wed Oct 09, 2013 5:00 pm

Hello you all.

Can any one explain a bit how to use the loginForm in a mobile solution?

Cheers,
Best regards,
Juan Antonio Santana Medina
[email protected]
EAGER BEAVER 2011
EAGER BEAVER 2012
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 540
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom

Re: Login Form

Postby johann.agcanas » Wed Oct 16, 2013 7:02 am

I'm gonna bump this for interest. Since the login method is through a form rather than a login solution as per normal Servoy, I assume it's implemented differently ? Documentation on a custom mobile login form doesn't seem to exist at all.
johann.agcanas
 
Posts: 5
Joined: Thu Sep 26, 2013 2:40 am

Re: Login Form

Postby jasantana » Wed Oct 16, 2013 9:36 am

Hi Johan.

You are right, the security.authenticate() method works slightly different. You do not need to send the authenticator solution nor the method, just the user name and password. Like security.authenticate(null,null,userName,userPwd).

But to be honest it does not work or I'm missing something because I'm not able to authenticate. Maybe some servoy gut can give us llight on this.

Cheers,
Best regards,
Juan Antonio Santana Medina
[email protected]
EAGER BEAVER 2011
EAGER BEAVER 2012
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 540
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom

Re: Login Form

Postby rgansevles » Wed Oct 23, 2013 9:53 am

Juan,

Did you try out the mobile sample, it uses logging in?

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1838
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Login Form

Postby jasantana » Thu Oct 24, 2013 10:02 am

Hi Rob.

It does but not with a custome login form
Best regards,
Juan Antonio Santana Medina
[email protected]
EAGER BEAVER 2011
EAGER BEAVER 2012
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 540
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom

Re: Login Form

Postby pbakker » Thu Oct 24, 2013 2:39 pm

I just tested and using a custom login for is straight forward: create a form and set it as the value for the loginForm property on solution level.

On the login form have whatever you need to collect the username and password from the user and then fire a call to security.authenticate(null, null, ['theUserName", "thePassword"]).

That should do the trick. In order to NOT get a alert saying that authentication failed on first launch, make sure to set the mustAuthenticate property on the Mobile solution to true. Without this setting it will still work, you just get an unneeded alert.

In the Service Solution you must of course implement the ws_authenticate method on the offline_data form or else no authentication is needed at all.

Paul
pbakker
 
Posts: 2817
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Login Form

Postby jdbruijn » Wed Oct 30, 2013 5:53 pm

i've just tried to modify my mobile solution to use a custom login form.
Running in chrome I get the new login form, and I can login (the ws_read method is triggered) but right after that I get a login popup from the browser and I cannot get past this.
My mobile solution is set to mustAuthenticate (it used the default login previously and that worked correctly)
Jos de Bruijn
Welcome CCS
Servoy Certified Developer
Image
jdbruijn
 
Posts: 445
Joined: Sun Apr 11, 2010 6:34 pm

Re: Login Form

Postby jcompagner » Wed Nov 27, 2013 5:34 pm

i guess the user/password combination is not correct, and then you are bumping against a browser (i guess you use chrome?) bug.
Because if a 401 status code is given back then for an ajax request, the browser takes over and shows its own login dialog.
The browser shouldn't do that it should give use the error callback that authentication fails. I think they are working on this.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Login Form

Postby marbeisol » Mon Mar 10, 2014 5:25 pm

Hello everyone!

I have a simple mobile app that asks for customer ID and retrieves his information from a Database, I created a custom login form and added the follow code:
var bResult = security.authenticate(null, null, [sUser,sPass])
if(!bResult){
plugins.dialogs.showWarningDialog("Test","User or password incorrect.")
exit()
return;
}
When runs the app on the Servoy Mobile, and I enter with a customer ID and password correct, I'm getting the message "User or password incorrect." then retrieves the information the customer ID. Otherwise when I enter with a customer ID or password incorrect I'm getting the same message, however the app retrieves other message " Authentication failed "
I am using Servoy Mobile Version: 7.3.0
Any ideas about how to make a user and password validation?
marbeisol
 
Posts: 17
Joined: Mon Feb 17, 2014 6:40 pm

Re: Login Form

Postby mattfrizzell » Mon Mar 10, 2014 11:05 pm

I use a call like this in my mobile client solution

Code: Select all
security.authenticate([sUsername, sPassword]);


And a call like this in my mobile service solution on my offline_data form

Code: Select all
function ws_authenticate(sUser, sPassword)
{
   var sUserID = security.getUserUID(sUser);
   if (!security.checkPassword(sUserID, sPassword)) {
      return false;
   }
   
   var oRetval = {
      username : sUser,
      userid : sUserID
   }
   return oRetval;
}


The only other thing you must make sure is correct are that your users are setup properly. Other than that, there isn't much going on to make this work.
Matt Frizzell
adBlocks
www.adblocks.com
mattfrizzell
 
Posts: 51
Joined: Mon Aug 21, 2006 4:00 pm

Re: Login Form

Postby jcompagner » Tue Mar 11, 2014 4:22 pm

in the mobile solution authenticate() call doesn't return anything
It can't return anything because the only thing it really does is set the user/pw combination ready for the sync/load data call to the server
All the calls to the server are also async (so using callbacks) to that method really can't return it directly because there is no direct call where we can wait for/on

If you have a custom login form that was shown as the result of a sync/loaddata call then when you call authenticate it will try to login and get data from the server
if login fails your login form is "shown again" and the user can fill in the right credentials and it can try again (again a call to authenticate())
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Login Form

Postby mattfrizzell » Tue Mar 11, 2014 4:32 pm

Yes, that was a bad copy and paste my actual method in the mobile solution is the following, I don't know what tab on my computer I grabbed that other bit. :oops:

Code: Select all
   security.authenticate([fvUsername, fvPassword]);
   forms.main.controller.show();
Matt Frizzell
adBlocks
www.adblocks.com
mattfrizzell
 
Posts: 51
Joined: Mon Aug 21, 2006 4:00 pm

Re: Login Form

Postby jd2p » Mon Mar 31, 2014 8:23 pm

jcompagner wrote:in the mobile solution authenticate() call doesn't return anything

Hi everyone! I was looking through this thread as I'm getting accustomed to servoy mobile. I was wondering, if this is the case, then how can one manage the message that is displayed to the user? Like saying that user/pwd is incorrect instead of letting the default servoy msg to appear?
Thanks!
JD
jd2p
 
Posts: 95
Joined: Thu Dec 08, 2011 1:08 am

Re: Login Form

Postby vschuurhof » Tue Apr 01, 2014 10:03 am

What you also can do is to perform a manual web service call for authentication before letting Servoy synchronizing the data. I have created a GET request like this:

Code: Select all
function authenticate(callbackSuccess, callbackError) {
   scopes.ui.showLoading(null, i18n.getI18NMessage('servoy.mobile.authenticating'));
   
   $.ajax({
      type: "GET",
      url: scopes.globals.serverURL + "/servoy-service/rest_ws/dss_mobile_service/authenticate/1/list",
      dataType: "json",
      async: true,
      timeout: 5000,
      beforeSend: function(header) {
         header.setRequestHeader("Authorization", "Basic " + scopes.encryption.encodeBase64(scopes.globals.username + ':' + scopes.globals.password));
      },
      success: function(result) {
         scopes.ui.hideLoading();
         
         callbackSuccess(result);
      },
      error: function(httpRequest, status, error) {
         scopes.ui.hideLoading();
         
         callbackError(httpRequest, status, error);
      }
   });
}


On server level, I created a form called "authenticate" which only authenticates the user. From there I return an object including a variable called "successful". Based on this I can determine whether authentication has been succesful and can even display a specific message to the user which I return in the same object. When successful I simply execute Servoy's synchronization mechanism.
Vincent Schuurhof
Servoy
vschuurhof
 
Posts: 69
Joined: Tue Dec 14, 2010 12:00 pm

Re: Login Form

Postby jd2p » Tue Apr 01, 2014 6:30 pm

Wow.. nice! I'm sorry, what is $.ajax function and how do you know about callback and those other functions?? I've been using restful WS on Servoy for a while based on the help file.. where did you learn all that? Thanks! I'll also try the manual webservice call you suggest.

JD
jd2p
 
Posts: 95
Joined: Thu Dec 08, 2011 1:08 am

Next

Return to Servoy Mobile

Who is online

Users browsing this forum: No registered users and 1 guest