Sign In Register

How can we help you today?

Start a new topic

Registering new user in auth request script

Hello,


I'm implementing an authentication system with a little added complexity.

Since we want to give the user the choice of adding custom username and password in the future, I'm structuring my custom social authentication scripts to be able to register a user via RegistrationRequest before the actual FacebookConnectRequest step.


The code works fine, in terms of creating the new user successfully, but it seems to fail the association of said user to the entity that sent the FacebookConnectRequest.


The result is the generation of two players, one tied to the RegistrationRequest and another one tied to the FacebookConnectRequest details.

I expect the FacebookConnectRequest step to link the social information to the player I create with the RegistrationRequest.

I'm sure I'm missing something, but I'm not entirely sure what.


Here's some code relative to what I'm doing, I'm pseudo-ing parts that are not strictly related for brevity.

 

if(haveScriptData)
{
    if( alreadyAuthenticated)
    {
        if( different person has the same social ID associated )
        {
            //Unrelated stuff
        }
    }
    else
    {
        if( Social ID is not associated to anyone )
        {
            if( some credentials missing)
            {
                Spark.setScriptError("error", "NO_CREDENTIALS");
            }
            else
            {
                // Create a new user
                var request = new SparkRequests.RegistrationRequest();
                request.displayName = displayName;
                request.password = password;
                request.userName = userName;
                var response = request.Send();
            }
        }
    }
    
    // If we reach this lines with nothing in ScriptError then we can regularly perform a social login
}  
else
{
    // If no scriptData has been passed in, set an error and output useful message
    Spark.setScriptError("error", "NO_DATA");    
}

 

Login to post a comment