-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Realm React
-
1 - XS (<= 1 day)
-
6180
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