Forum C# How can I tell if a user is a guest?

How can I tell if a user is a guest?

Postby wgfunstorm » September 13th, 2012, 1:26 pm

I have 2 types of users:

Guests -> log in using PlayerIO.connect and randomized guest name -> should not store/load from DB
Registered users -> log in using simple users -> should store/load from DB

My problem is I can't find a good way to tell if a user is a guest.

I could check if their username starts in "Guest-" but that's not really secure if somebody figures out a way to send a different username as a guest (eg by decompiling the game). Or I could put a "isGuest: true" property in the join data but again this could be disabled by someone determined.

This is a problem because playerObject is automatically created if the player doesn't exist, and I don't want this to happen if someone is a guest! In short, what I want is a good way to do "if (player != guest) { loadPlayerObject(); }"
Last edited by wgfunstorm on September 13th, 2012, 3:37 pm, edited 1 time in total.
wgfunstorm
 
Posts: 16
Joined: January 21st, 2012, 4:10 pm

Re: How can I tell if a user is a guest?

Postby dreamora » September 13th, 2012, 3:28 pm

its easy: see if the players PlayerObject is actually persistent and only store the playerobject for non guests
The playerobject will not be stored automatically without you telling Player.IO to save the object, hence upon disconnect its gone.

That is if you use the normal connect path, not the 'do nothing yourself and let player.io handle it' paths for which I'm not sure how it works in such cases
dreamora
 
Posts: 225
Joined: March 2nd, 2012, 9:58 am

Re: How can I tell if a user is a guest?

Postby wgfunstorm » September 13th, 2012, 3:47 pm

dreamora wrote:its easy: see if the players PlayerObject is actually persistent and only store the playerobject for non guests
The playerobject will not be stored automatically without you telling Player.IO to save the object, hence upon disconnect its gone.


As you suggest, I only want to store it for non-guests, but my problem is that I don't have a good way of knowing if the user is a guest, so I don't know whether to store it or not.

That is if you use the normal connect path, not the 'do nothing yourself and let player.io handle it' paths for which I'm not sure how it works in such cases


I have no idea what this means...

I'm using player object as documented here http://playerio.com/documentation/bigdb/playerobject
Connect for guests http://playerio.com/documentation/refer ... io#connect
And connect for simple users for registered users http://playerio.com/documentation/quick ... impleusers
wgfunstorm
 
Posts: 16
Joined: January 21st, 2012, 4:10 pm

Re: How can I tell if a user is a guest?

Postby Henrik » September 13th, 2012, 7:34 pm

The best way to solve your problem is to use multiple connections (http://playerio.com/documentation/connections) and restrict the guest connection so they can't do anything in BigDB. That way you can still do the check if the connectUserId contains "guest", and if someone makes a hacked client that connects as something else, they still can't access BigDB.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: How can I tell if a user is a guest?

Postby wgfunstorm » September 15th, 2012, 12:42 am

Thanks, this sounds like a good solution but since it's unfortunately a paid feature I guess I will implement it last before launching and just continue to check the username for guest for now.
wgfunstorm
 
Posts: 16
Joined: January 21st, 2012, 4:10 pm

Re: How can I tell if a user is a guest?

Postby dreamora » September 15th, 2012, 9:17 am

DatabaseObject (http://playerio.com/documentation/refer ... baseobject), which is what PlayerObjects are, has the property ExistsInDatabase (http://playerio.com/documentation/refer ... InDatabase) which you can use to check if it exists in the db or not.
A PlayerObject should return false until you properly saved it through usage of the Save function
dreamora
 
Posts: 225
Joined: March 2nd, 2012, 9:58 am

Re: How can I tell if a user is a guest?

Postby Benjaminsen » September 15th, 2012, 6:22 pm

We are aware of the slight issues guests systems provide, and have talked about adding a guest service to QuickConnect. However a method I have liked is simply having a QuickConnect simpleuser with a public username/password. Then you can simply check on their connectUserId.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: How can I tell if a user is a guest?

Postby wgfunstorm » September 23rd, 2012, 12:50 am

Thanks Benjaminsen, I ended up doing it like you suggested.

However I changed my mind - I want to store guest data after all, and delete it when guests disconnect.

For that to work, I need each guest to connect as a different user so they can have their own playerobject. So now I am generating a uuid for each guest, and will use the connection method you suggested earlier to identify them as guests.

However I'm not sure how I can delete data when a guest disconnects. I made a new thread about it and would appreciate any suggestions you may have: post43505
wgfunstorm
 
Posts: 16
Joined: January 21st, 2012, 4:10 pm


Return to C#