AS3 UserService.authenticate() returns error 2002 for NULL Users

0 votes

When sending an UserService.authenticate request for a user that I have not created, I am getting a 2002 error: User name/Password does not match. Authentication Failed instead of a 2006 error: User does not exist.

I use 2 classes, the Server_Backend to call my api services and the callback with customized error handling. The ultimate goal for this code is to send the user to the create new account page if the authentication does not find the user in the user db. Code works when creating a user or authenticating an existing user.

Any guidance will be appreciated.

Here is the code for the Backend Class:


package Utilities
{
public class Server_Backend
{
private static const SERVICE_TOKEN:Array = new Array(Encyc.KEY,Encyc.SECRET);
private static const SERVICE_API:ServiceAPI = new ServiceAPI(SERVICE_TOKEN[0], SERVICE_TOKEN[1]);
private static const USER_SERVICE:UserService = SERVICE_API.buildUserService();
 
public static function CreateUser(userName:String, password:String, email:String):void
{
USER_SERVICE.createUser(userName, password, email, new callback());
}
 
public static function GetUser(userName:String):void
{
USER_SERVICE.getUser(userName, new callback());
}
 
public static function AuthenticateUser(userName:String, password:String):void
{
USER_SERVICE.authenticate(userName, password, new callback());
}
}
}

 

Here is my callback class (condensed):


public class callback implements App42CallBack 
{
public var USER:User;
 
public function onException(exception:App42Exception):void 
{
var appError:int = exception.getAppErrorCode();
switch (appError) 
{
...
...
...
...
case 2001:
trace("Server_Callback: Username " + USER.userName + " already exists!");
break;
case 2002:
trace("Server_Callback: Username/Password does not match. Authentication Failed.");
break;
case 2004:
trace("Server_Callback: User with the emailId " + USER.email + " does not exist.");
break;
case 2005:
trace("Server_Callback: The request parameters are invalid. User with emailId " + USER.email + " already exists!");
break;
case 2006:
trace("Server_Callback: User does not exist!");
break;
...
...
...
}
}
 
public function onSuccess(response:Object):void 
{
USER = User(response);
}
 
}

 

asked Jul 2, 2015 in App42 Cloud API-BaaS by byteme.cybertech (11 points)
reshown Jul 3, 2015 by byteme.cybertech
Well, my current work around is calling createuser and setting an event dispatcher in the exception handler. If the app error is 2001, I check if the user sent from the login page or the create user page. If it is from the login page, i direct it to authenticate function.

This seems too hacky to be the way authentication is done, unless I missed a section of the instructions.

1 Answer

+1 vote

Hello,

As of now, this feature is not avaiable. However you can maintain it locally by checking the user info in App42 data base using getUser API. Meawhile, I am recoreding your request in our product pipeline which you can find from here. We will update this thread once it will be available for use. Also, you can track your request from the link as well. 

Let me know if you need any other help regarding this. 

Thanks,

Himanshu Sharma

answered Jul 3, 2015 by hs00105 (2,005 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...