Empty object user when authenticating with Realm.Credentials.jwt(token) and Realm connection issue with RN hot reload

試著忘記壹切 提交于 2021-01-06 03:27:16

问题


I am trying to use Mongo Realm (v10.0.0-beta.9) ; I use a JWT authentication (token being generated by AWS Cognito). It works pretty well since a user has been created (in Mongo Realms Users menu) and I was able to insert a data in my realm. But...

1. Empty user object

One strange thing nevertheless: the user I get from the authentication is empty

  const credentials = Realm.Credentials.custom(jwt)
    // Authenticate the user
  const user: Realm.User = await app.logIn(credentials)
  console.log("logged in with Jwt, user:", user) // display "logged in with Jwt, user: {}"

Is it normal? Examples speak about a identity field: console.log(`Logged in as ${newUser.identity}`);

2. React Native hot reload

A bothering thing: I can't reconnect to a realm when reloading the app (pressing r in the console where I npm started). I don't get any error, I just get... nothing. No log appears in Realm console. The only solution I get is to kill the app, then restart it.

Did I miss a trick to handle that reconnection with RN hot relad?


回答1:


I've had some troubles converting any Realm objects to printable strings; I always get {} just like you do. I think it could be related to this (unresolved) task on their GitHub.

On a similar note, there are some bugs in Realm's authentication system. I'm trying to get email/password, Facebook, and Google authentication going in my application but all of them currently seem to be broken on Realm's side.

Here are some related issues on their GitHub that you can follow for a solution.

  • Facebook
  • Google
  • Email/pass (fixed, but not released in the latest beta)

I don't have any information about JWT specifically but given these other authentication issues there's a good chance the issue isn't on your side. I recommend opening an Issue on their repository.



来源:https://stackoverflow.com/questions/63268611/empty-object-user-when-authenticating-with-realm-credentials-jwttoken-and-real

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!