I'm new to GameSparks and trying to implement some basic functionality for my UE4 game. My question right now is just pertaining to the test harness though.
I'm trying to setup a system to prevent multiple logins from the same player. I do not want a login to disconnect the current active session, but rather throw an error saying that the account is already logged in and do not proceed with authentication. I am a vfx artist by trade, not a programmer so I'm probably missing something obvious.
Right now I have the following cloud code on authentication response to check if the player is logged in, throw an error if so, and if not proceed and set the status to true.:
var IsLoggedIn = Spark.getPlayer().getScriptData("IsLoggedIn");
if (IsLoggedIn !== null && IsLoggedIn) throw "ALREADY_LOGGED_IN";
On PlayerDisconnect I have the following code to remove the IsLoggedIn script and reset auth tokens:
The problem I am having is as follows. On the test harness I send an authentication response request to log in and everything works. Then I attempt a second login to hopefully throw the error and not work. Here's where my issue comes in. On the second log-in attempt the test harness does indeed throw the error "ALREADY_LOGGED_IN", however when I check the database afterwards I see that there are now 2 auth tokens rather than 1, which leads me to believe that a second login was successful despite that error being thrown. How would I prevent this and end the authentication response upon error?