question

Darius Vu avatar image
Darius Vu asked

How to write the Azure Functions to do the password resetting?

Dear Support Team,

I am reffering this quickstart to make the PlayFab CloudScript - "ResetPassword" using Azure Functions.

https://docs.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/quickstart

Now, I can create a function and publish it in Azure. Then I can register this function in Playfab site and call it in Unity client.

However, now I don't know how to write the "ResetPassword.cs" to use the Token stored in Internal Data and the new password from users to call ResetPassword to do the password resetting. So could you help me to write the "ResetPassword.cs" example in Azure function?

I am grateful so much for your support!!!

10 |1200

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

1 Answer

·
Seth Du avatar image
Seth Du answered

I assume that you have created a Rule, which will monitor the “auth_token_validated” event and execute a Cloud Script/Azure Function to read the Token parameter from the triggered event, then store it into a player’s Player Internal Data.

Client-side will have to ask for the player to change the password. Client will need to call ExecuteFunction API, and submit the desired password in the request as a parameter. In the Azure function, it will firstly check Player Internal Data via Server API or Admin API GetUserInternalData, to verify that caller has the specific key you defined for Token, after that, Admin API ResetPassword will be called to make the change, reading password from function argument:

dynamic args = context.FunctionArgument;
8 comments
10 |1200

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

Darius Vu avatar image Darius Vu commented ·

Hi SethDu,

Thank you so much for your help. I understand about this process.

Currently, I have the Cloud Script "storeToken" to store the Token when user click on "URLConfirmation" in the email verification. And the token is stored in Player Internal Data.

But I am facing the issue how to write the Azure function using Playfab API to get check Player Internal Data and verify the token and call ResetPassword API function.

Could you give me the example for that?

0 Likes 0 ·
Darius Vu avatar image Darius Vu commented ·

Thank you so much!! I will refer your code to implement it.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ commented ·

PlayFab official repository provides detailed samples of Azure Function usage. You may refer to: https://github.com/PlayFab/PlayFab-Samples/tree/master/Samples/CSharp/AzureFunctions

0 Likes 0 ·
Darius Vu avatar image Darius Vu Seth Du ♦ commented ·

Hi SethDu,

I am referring your code. But it has the issue as picture below that PlayFab.AdminModels is missing as the reference although I installed PlayfabAllSDK using this: dotnet add package PlayFabAllSDK

Will I have to install any extension to using PlayFab.AdminModels?

capture3.png

0 Likes 0 ·
capture2.png (93.7 KiB)
capture3.png (38.0 KiB)

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.