Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-2591

(@realm/react) `useEmailPasswordAuth.register` should return a promise

      Problem

      For the useEmailPasswordAuth() hook, it would be great if register() returned a promise instead of void. The SDK's app.emailPasswordAuth.registerUser does that. Without returning a promise, it can be hard to work with a sequence of events, like linking identities.

      For example:

      Unable to find source-code formatter for language: ts. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      const registerAndLinkIdentities = async () => {
          try {
      	  // Could await old method.
            // await app.emailPasswordAuth.registerUser({email, password})
      		
      	  // Can't await `register`
            register({email, password});
      ​
            const credentials = Credentials.emailPassword(email, password);
      	  // Which leads to "invalid username/password" here and aborts the
      	  // still running registration process.
            await user.linkCredentials(credentials);
      ​
          } catch (error) {
            // Add error handling logic here
            console.error(error);
          }
      };
      

      Solution

      useEmailPasswordAuth.register should return a promise that resolves based on app.emailPasswordAuth.registerUser's behavior.

      Alternatives

      No response

      How important is this improvement for you?

      I would like to have it but have a workaround

      Feature would mainly be used with

      Atlas App Services: Auth or Functions etc

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: