Email Confirmation Script for User Authentication via Email Address

I’m looking to move across from Firebase to MongoDB (for a number of reasons). But user authentication is a little more “involved”. Based on the Realm UI, I’m required to enter an “email confirmation URL” that should point to a page that contains an email confirmation script.

I’ve tried to look for some tutorials or guides on how to configure this as I’m new to programming. Can anyone point me in the right direction please?

Hi @Anthony_CJ,

The idea is you should set a link pointing to your application url endpoint where you would confirm the received token.

Now the user is sended with an email by Realm system after registration the link he clicks should point to a place where you complete your registration with your sdk language.

Here is the section for user confirmation flow for JS sdk (you should navigate to a similar docs for your sdk):

https://docs.mongodb.com/realm/node/manage-email-password-users#complete-a-user-confirmation

Please let me know if this helps.

Best
Pavel

Thanks. I understand the process, what I don’t know how to do is generate the email configuration script that I will locate at the email confirmation URL. I am building an iOS app so there’s so web app.

Hi @Anthony_CJ

This is more related to language specific redirect, you can also avoid email confirmation or do a function confirmation for your app.

I would recommend looking into our IOS tutorial which shows email signup logic:
https://docs.mongodb.com/realm/tutorial/ios-swift#enable-authentication

Best
Pavel

Hi @Pavel_Duchovny. Thanks but I’ve got that bit sorted. That’s not what I’m asking about. I’m asking about the email confirmation URL and generating an email confirmation script.

I have exactly the same question mark. It seems like you have to set up you own website with scripts to handle the confirmation link. Apparently in previous versions (Realm Cloud or Stitch) they provided this service for the clients but not anymore. I’m trying to develop a desktop app with Realm, so I don’t have a webserver, which could do that job. Thus this feature is not really useable for me.
Using custom functions to might be the answer, but because of a lack of examples I don’t see how I still can validate that users provided a valid email (for password resets) .

Hi @Anthony_CJ,

I think its definitely possible to create a link which redirect to your ios app instead of a web page:

https://stackoverflow.com/questions/15621641/ios-url-redirect-from-mail-to-app

This is a bit out of scope for realm per say.

The code to confirm is:
https://docs.mongodb.com/realm/ios/manage-email-password-users#confirm-a-new-user-s-email-address

As I said if you don’t want to use an email you can send the user SMS via twilio or email with a code and have the confirmation function input this code from email.

Thanks
Pavel