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);
}
}