Jorge Gonzalez avatar image
Jorge Gonzalez asked

Player management in Playfab

I need to create different type of accounts for an app. I need an Admin, Distributor and Costumer. Admin can create Distributors and Distributors can create Costumers. I am thinking of Storing stats to determine what type of permissions each user has. I think I can do the rest in the game. The problem I have is creating the Admin Account.

I want to be able to create it from Playfab manager. Unless I should do it differently. I can create a player, put the email. Then I got to playfab login and send the reset password. It all works up to the username. I can't edit that. Without the username the player can't use login using playfab request. I decided to create a dummy scene to play in unity and use that to create the player with the playfab account. Then send the reset password from Playfab manager.

I wanted to check some things before I dig in deep.
1. Am I in the right track doing things the way I am now?
2. Is there a way to create a player with a login using Playfab Manager?
3. Is there something set up in Playfab that I am missing; something that I should be using to make this set up easier? I don't want to re-invent the wheel. Hope my concern and question make sense.

Player Datagame manager
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jorge Gonzalez avatar image Jorge Gonzalez commented ·

I am planning on having all 3 users be players with different stats. Player with admin stat, Player with Distributor stat and Player with Costumer stat. (In case that wasn't clear)

0 Likes 0 ·

1 Answer

Citrus Yan avatar image
Citrus Yan answered

Players created from the Game Manager are associated with a Custom Id:

You can use that with the LoginWithCustomID API to sign in that player, once logged in, call AddUsernamePassword to add username, email and password for that player.

Or, you can just use the RegisterPlayFabUser API to create a new player with username, email and password without having to manually create a player in Game Manager first and then add username and password for it. However, please note that this is a API that requires no authentication, so theoretically speaking every player can make a call to this to create a new player, which I assume may affect your game logic. You can choose to disable this API, more details please see:

Apart from using statistics to denote admin/distributor/consumer players, you can also consider using readonly/internal player data for this:

pic.png (15.8 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

And, in your game, admin and distributor accounts can create new PlayFab accounts, please note that's not something PlayFab natively supports, you may prevent the client-side from doing it directly and implement a custom server to handle such logics instead:

1. Verify the player's role. either through stats or readonly/internal player data mentioned above.

2. If true, create new accounts as the players requested. To automatically create accounts instead of manually creating it from the Game Manager, you can call the server API LoginWithServerCustomId (the custom id should be unique for each player ) to create and login an account (CreateAccount set as true), after logged in, use AddUsernamePassword to add username, email & password for that player.

0 Likes 0 ·
Jorge Gonzalez avatar image Jorge Gonzalez Citrus Yan commented ·

When you say Custom Server, could most of the data managing be handle via cloud script? Like creating new account through custom ID and Adding username and email?

Then using cloud script to get that player's info? The Distributors and Admins need to be able to edit Costumer info as well as their own. Is it possible, if I check permission, to be able to edit the name on a player? I am not too worry about cheating or hacking much as the only sensitive information is the email and that won't change.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Jorge Gonzalez commented ·

Server and Entity APIs are integrated into the CloudScript environment, therefore in CloudScript you can use & to access those APIs. However, client APIs are not integrated, in your case, it means that you cannot directly access the client API AddUsernamePassword in CloudScript unless manually make a http request to it, which is not recommended. Therefore, a custom server would be more convenient to implement your use case.

If you insist on using CloudScript, as a workaround, you can have the CloudScript function return the Sessionticket received from the LoginWithServerCustomId call back to the client-side and let the admin/distributor add username, email & password on behalf of the account. And handle most of the data managing job via CloudScript, that'll work.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.