Centralized login for various apps

Hi everyone.

I want to create a centralized login for my apps.

I’m using the MongoDB Atlas free-tier and Reactjs.

I have got various applications and I want to create the same login system for all the apps.
I am thinking in creating a separate cluster that will have configured the email & password provider. The problem is that if I create a custom authentication function I already need another authentication method. No?

Can you inform me about how to do that? Which are the best practises?

Thanks in advance,
Juanjo Asensio García

i don’t understand what you mean by this.

Maybe explain your high level use case and/or work flow first so everyone can understand it better.

The problem is that I don’t know how to write a custom authentication function properly.
I first thought in creating a custom authorization function that:

  1. Imports Realm-Web as dependency
  2. Set my separated Login App Service as the Realm App
  3. Authenticate with the provided email and password in my Login App
  4. Return the user of Login App if all went OK

But I get the following error:

failed to execute source for 'node_modules/realm-web/dist/bundle.cjs.js': TypeError: Cannot access member 'name' of undefined
	at node_modules/realm-web/dist/bundle.cjs.js:4260:29(737)
	at require (native)
	at function.js:15:3(12)
	at <eval>:3:8(7)
	at <eval>:2:15(7)
	at native

Do you know how to fix it?

Hi @Juan_Jose_Asensio_Garcia,

The app services function engine has some limitations on the dependencies it supports, and it appears that realm-web is using an unsupported process call so you cannot use it as a dependency for now. In the meantime, I would recommend using the client API to authenticate the user using this endpoint.

Thank you very much! I have fixed it.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.