realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.72k stars 564 forks source link

Refactor the Authentication Patterns in Realm JS #4481

Open sync-by-unito[bot] opened 2 years ago

sync-by-unito[bot] commented 2 years ago

Authentication in Realm is wrapped in nested namespaces, which makes the process not entirely straightforward. I believe we should rethink the way authentication is done and come up with a more ergonomic interface.

For example:

// login
  const creds = Realm.Credentials.emailPassword(email, password);
  await app.logIn(creds);

// register
 await app.emailPasswordAuth.registerUser({email, password});

In most cases, all required parameters for authentication are nested. Perhaps something like:

import {emailPassword} from '@realm/auth'

emailPassword.login()
emailPassword.register()
takameyer commented 1 year ago

I believe that:

await app.emailPassword.registerUser({email, password});

Is a bit ambiguous. I would like to rethink the entire authentication flow to be more ergonomic and break it even more than just renaming some parts of it.