DEV Community

Discussion on: MongoDB Atlas Hackathon Help Thread

Collapse
kmukabe profile image
Kacha • Edited on

Hi @thepracticaldev , I'd love some help from the MongoDB team or anyone who has come across this. I have a realm app with email/password authentication enabled and I have a react native app that does sign up and sign in.
When using the sign in method from the realm library:

const creds = Realm.Credentials.emailPassword(email, password);
const user = await Realm.app.logIn(creds);
Enter fullscreen mode Exit fullscreen mode

when I console log the user I get an empty object { } but when I call user.id I get the id of the user object. I'm not entirely sure what I have done wrong but I think this is causing further errors because I am getting an error when I try to open a realm connection with this user.
Any help would be great.

Collapse
joellord profile image
Joel Lord

Hi,

For more technical questions, you might want to try to search or post on our community forums (mongodb.com/community/forums/), you will normally get a quicker answer there. As for your question, you could try creating an object that contains your application, and then use the methods for this application. Right now, I’m not sure if your Realm.app is an initialized property. You could try this out:

const app = new Realm.App({ id: "<APP_ID>" });
const credentials = Realm.Credentials.emailPassword(email, password);
const user = await app.login(credentials);
const userProfile = app.currentUser;
const userId = app.currentUser.id;
Enter fullscreen mode Exit fullscreen mode

I hope this helps!