• 0 Votes
    2 Posts
    261 Views

    Hi Kuabs, you can use brainCloud webhooks to achieve this feature, the steps are as follows.

    Create a cloud code script, in this example use the name "webhook_forgotPassword", and paste the following code into the script. "use strict"; function main() { var response = {}; bridge.logDebugJson("Script inputs", data); var userEmail = data.parameters.email; response.stringResponse = "webhook is processing user email reseting..." + data.parameters.email; // validating the user email if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(userEmail)) { // checking if the email is existed in brainCloud users var context = { "pagination": { "rowsPerPage": 20, "pageNumber": 1 }, "searchCriteria": { "emailAddress": userEmail }, "sortCriteria": { "playerName": 1 } }; var userProxy = bridge.getUserServiceProxy(); var postResult = userProxy.sysGetPage(context); if (postResult.data.results.count > 0) { var userProfileID = postResult.data.results.items[0].profileId; // sending password reset email postResult = userProxy.sysSendPasswordResetEmail(userProfileID); if (postResult.status == 200) { response.stringResponse = "password reset email has been sent to user's email:" + userEmail; } else { response.stringResponse = "system error with sending email..."; } } else { response.stringResponse = "user doesn't exist with the email you provided"; } } else { response.stringResponse = "user's email is invalid."; } return response; } main();

    Open Design | Cloud Code | WebHooks page, and create a WebHook link to the script you created from the previous step. Copy down the WebHook URL for the next step.73ee4986-3d38-4694-bac5-d7c4896c99ba-image.png

    Now, you have completed the work from brainCloud. Next, open your client app editor (if you are using Unity), define the WebHook URL as a variable, and link it to your forgotEmail object (could be a link or button in your app) onClick event, making it trigger this URL when the user clicks with Application.OpenURL command. Grab user inputted email and append it as an email parameter to the URL as follows:

    const string passwordResetWebhookUrl = "https://portal.braincloudservers.com/webhook/12832/forgotPassword/6dc675bb-f8b4-495f-ac5e-1f0658bfe09c"; Application.OpenURL(passwordResetWebhookUrl + "?email=" + userEmail);

    Run your app to test, you should get a similar pop-up window as follows once a user clicks the forgotEmail object,
    94dd0dae-7d6e-44c8-ab26-0d57a8544bb4-image.png

    Check the reset email in your test email account...25a6f240-5246-4ba2-a216-e978eaccee8c-image.png

  • 0 Votes
    2 Posts
    248 Views

    It's not. Just knowing a playerId is really not important as it's only a unique identifier for another player and nothing more than that.

  • 0 Votes
    3 Posts
    367 Views

    @panagiotis-milios Thank you for your response, appreciate your time !
    I solved the issue :
    The url I was using was wrong, more precisely I was using the wrong servlet :
    I was using

    /dispatcherv2

    while I was supposed to use

    /s2sdispatcher.

    I also want to point out that you are right about the "appId" below the "packetId", it is not needed.
    Thank you, I hope this thread will help anyone encountering this problem !

  • 0 Votes
    5 Posts
    286 Views

    Hello @Gavin-Beard!

    We've had trouble reproducing this issue on our end. After some testing with a small app on MacOS and iOS, we have not been able to see the error you are encountering using Unity 2021.3.8.

    If you could, please check out the app here and let us know if this issue is still persisting. It is a barebones authentication app and it should run on multiple devices. The Authentication.cs script has all the gory details. Just open up the Main scene under Assets > App > Misc > Main.unity to get it running. You will also need to add your brainCloud credentials, but you can copy the Authentication example template in brainCloud to test the app.

    Please let us know how this app works on your end and if any issues are encountered! You should be able to click on any error logs in the in-app console to copy the log to your device's clipboard.

    As for your specific issue, my best guess is that perhaps an external library of sorts might not be supported with brainCloud, such as the Newtonsoft Json.NET library. For JSON de/serializing, brainCloud comes with JsonFX. You can also make use of Unity's own JsonUtility for structured JSON de/serialization. Both the app I've shared and the examples on our GitHub make use of JsonFX extensively.

    If you'd like to know more and see how a more robust app can handle brainCloud authentication, as Franco suggested, you should check out our Authentication example on our Unity Examples GitHub.

    Hope this helps! Please let us know if you have further questions or inquiries about this.

  • 0 Votes
    3 Posts
    342 Views

    @JasonL Thanks, I ended up with this cloudCode:

    isForceCreate = String(data.callingMessage.forceCreate) == "true"; isNewUser = String(data.message.newUser) == "true"; var response = {}; response.status = 200; response.data = data.message; if (isForceCreate && isNewUser) { var min = 10000000, max = 999999999 prefix = ["player", "user", "member"] const num = Math.floor(Math.random() * (max - min + 1)) + min; const pre = prefix[Math.floor(Math.random() * prefix.length)]; var defaultPlayerName = pre + String(num); var playerStateProxy = bridge.getPlayerStateServiceProxy(); // We are changing the player name on the server. playerStateProxy.updatePlayerName(defaultPlayerName); // And in this API Call's return data. response.data.playerName = pre + String(num); } response; //return the object

    This works just the way I need

  • 0 Votes
    2 Posts
    272 Views

    Call AttachUniversalIdentity() method from client lib, the username is uniqueness enforced.

  • 0 Votes
    1 Posts
    135 Views
    No one has replied
  • 0 Votes
    1 Posts
    122 Views
    No one has replied
  • 0 Votes
    2 Posts
    181 Views

    I downloaded the BrianCloud plug in for Unreal Engine, I can integrate user authentication, and real-time chat between connected players in a day.

  • 0 Votes
    4 Posts
    301 Views

    @JasonL I understand the reason, but please do provide a way to pass custom data to authenticate api so we can use that data to set user displayname or profile picture or soemthing else on post-hook.
    Without this, we have no choice but to call a seperate call from client (so no beneift of 2 free api inside cloud call)

  • [Unity] Authenticated Event ?

    Solved APIs
    2
    0 Votes
    2 Posts
    212 Views

    Hmm, actually Eric, authentication only happens when called directly in brainCloud.

    If you try calling an API and your app isn't authenticated, you'll receive an error - and generally would trigger authentication yourself as part of your error handling.

    Does that make sense?

    Paul.