How do you access Realm Auth or even Realm from functions ? I want to create a user or reset password from a Realm function.
Thanks.
How do you access Realm Auth or even Realm from functions ? I want to create a user or reset password from a Realm function.
Thanks.
You can use the Admin API within functions to create users and a password reset function can be set from the UI in ‘Email/Password Provider’
To call the Admin API from a function, you can see an example in a function by Pavel here.
Interresting, thanks. I’ll look at it.
It’s too bad that there is no easier way. I thought that Realm functions had similar access as api functions do.
They have access to mongodb and services, why don’t they have access to users (auth) as well ?
I think the rational is that functions are meant to be user interaction with logic and services and not administration of users or provisioning.
I know that user administration is a gray area where we get more and more feedback that we should. Probably offer some better programmatic api for it… CC: @Drew_DiPalma
Thanks
Pavel
Said that way, it all makes sense now.
Actually it’s not really user management that I want to do. Are you thinking of adding a password requirements such as AWS has. Adding user pool password requirements - Amazon Cognito
That would be nice, I wouldn’t have to use the realm api in a functions to wrap the creation of users.
The password restrictions is build in for email password and currently only enforced.
Perhaps, for a more dedicated logic of Auth you can use custom-function authentication where you can do whatever checks you like for passwords:
https://docs.mongodb.com/realm/authentication/custom-function/
Thanks
Pavel
Yes i’m using email/password auth. I’m not sure what you mean by enforce. I know that they allow any types of password without restrictions, is this correct?
Edit: I guess i should try custom auth function, although that will be more work.
@David_N_A,
Password is restricted between 6 and 128 characters for node sdk:
https://docs.mongodb.com/realm/node/manage-email-password-users/#register-a-new-user-account
I assume similar restrictions for other sdks.
Best
Pavel
Ok thank you.
I will either build a password format validation on React and then Realm will only check the password length. (yuk…)
Or I will use the custom auth function on Realm to build a password format validation there.
@David_N_A - thanks for explaining your use-case + feedback here. If you add your feature request here Realm: Top (70 ideas) – MongoDB Feedback Engine, we can track how many other users are also interested in something like this.