Sign In Register

How can we help you today?

Start a new topic

Preventing concurrent login

Our game has a requirement that every user cannot log in to multiple devices at the same time. In order to achieve this, I use Spark.getPlayer().disconnect(true). The problem with this, is the devices that don't receive SessionTerminatedMessage(because not connected to the internet or other reasons) is still authorized as the user the next time they're connected. I've tried to use Spark.getPlayer().resetAuthTokens() after disconnecting the player, it works but it also affects the current user to be unauthorized.


Any advice to achieve this?


2 people have this question

bump

Hey Samuel,

Are you using some player details from the client-side, like username and password to make sure a player is logging in the same on each device?
I just ask to make sure you are not using a device-authenication, because that could be a little tricky for what you want achieve.

So, when a player logs from a second device, you would like the session on the other device to be terminated, and the player to be authenticated again with the seconds device. Something like that, am i right?

-Sean

 

Hi Sean, I'm using both username-password login and the social ones like Facebook. Yes that's exacly what I want.

Hi admin, I don't consider this as an answer, I was just stating what I want to do, and still don't get an answer on how to do it.

Hey Samuel,

Sorry about that mistake, im going to get back to you asap.

-Sean

 

And my apologies for not getting back to you sooner, i didn't see you had replied.

 

Hey Samuel,

Unfortunately there isn't anything we can do about that since, once the player is disconnected we cant send a message to them anyway. And if they login, they will kick off the second user, and you have the same problem.

 One solution you might use to detect the SessesionTerminatedMessage sent when you use disconnect(true) as a push notification instead of through the socket, and tell the player they have been disconnect that way. This might be more complicated than you want, but its the only solution i can think of at the moment.


Sorry i couldn't be more helpful. I will continue to investigate a solution and keep you updated.

-Sean

Hi Sean,


It's a shame that there's no easy way round, but I really appreciate your effort, thanks. I'll keep trying to find another solution


Samuel

we are also running into the same problem. this would seem like a common problem for almost all online games, so i imagine many of us gamesparks developers must also be facing this same problem. 


is there any recommended best practice on preventing concurrent logins from the same user? 

I'm also interested in a solution, I would like to forbid users to log simultaneously on different devices (as lots of games actually do)...

I just realized I have the same problem, and I am surprised there is not easy way solution to it, since this must be a problem for every single game. Anybody found an easy way how to prevent concurrent logins?

ask the same here:
https://support.gamesparks.net/support/discussions/topics/1000074708

 

Hi Guys,


Good news. We've added functionality to prevent this in Cloud Code. You can use "Spark.getPlayer().resetAuthTokens(true)" to reset all auth tokens excluding the latest. Try it and if you have any further questions just let us know.


Regards,

Liam


1 person likes this


I think the solution presented is not yet adequate,

2 years and nothing was done


We need this:


AuthenticationRequest

Request Parameters

Parameter: MULTIPLE LOGIN

Required: NO

Type: bool

Description: case false disable multiple login and return an error when a new device try to login

Error Codes

Key : DETAILS

Value: ALREADY_LOGGED

Description:

The player is already logged in, disconnect the other instance and try again




4 people like this
Login to post a comment