I use this code in my Azure function to get the stored password recovery email token. The token is automatically saved when the player clicks on the link in his password recovery email.
var getUserInternalDataResponse = await adminApi.GetUserInternalDataAsync(new PlayFab.AdminModels.GetUserDataRequest(){ PlayFabId = playfabid, Keys = new List<string> () {"ResetPasswordToken"} }); if (getUserInternalDataResponse.Error != null) { log.LogInformation($"Error: = {getUserInternalDataResponse.Error.Error}"); var errors = OnPlayFabError(getUserInternalDataResponse.Error, language); errorline1 = errors[0]; errorline2 = errors[1]; errorline3 = errors[2]; errorline4 = errors[3]; return new Result { FunctionSuccessful = false, Errorline1 = errorline1, Errorline2 = errorline2, Errorline3 = errorline3, Errorline4 = errorline4 }; } else { var tokenId = getUserInternalDataResponse.Result.Data["ResetPasswordToken"].Value; log.LogInformation($"tokenId = {tokenId}"); // change password here ... }
But when the player calls my Azure function "ChangePasswordUpdate" without having clicked on the link in his password recovery email, then the player gets the following error message in my game:
"Invocation of cloud script function ChangePasswordUpdate failed"
The problem is, the player doesn't know what he did wrong when I display this error message in my game. Therefore, I want to find out in my Azure function if "ResetPasswordToken" exists in internal data. If not, then I want to display this custom error message in my game:
We have send you an email. You need to click on the link in this email before you can change your password.
How can I find out in my Azure function if "ResetPasswordToken" exists in player internal data so that I can display my custom error message in my game when the player forgot to click on the link?