使用Realm.Credentials.jwt(token)进行身份验证时出现空对象用户,并且RN热重载导致Realm连接问题 [英] Empty object user when authenticating with Realm.Credentials.jwt(token) and Realm connection issue with RN hot reload

查看:64
本文介绍了使用Realm.Credentials.jwt(token)进行身份验证时出现空对象用户,并且RN热重载导致Realm连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Mongo Realm(v10.0.0-beta.9);我使用JWT身份验证(令牌由AWS Cognito生成).由于已经创建了用户(在Mongo Realms用户菜单中),并且我能够在我的领域中插入数据,因此它运行良好.但是...

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.空用户对象

不过,有一件奇怪的事:我从身份验证中获得的用户是空的

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: {}"

正常吗?示例涉及一个身份字段: console.log(`登录为$ {newUser.identity}`);

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

2.反应本机热重装

一个麻烦的事情:重新加载应用程序时,我无法重新连接到领域(在我启动npm的控制台中按 r ).我没有得到任何错误,我只是得到了……什么都没有.Realm控制台中没有日志.我得到的唯一解决方案是杀死该应用程序,然后重新启动它.

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.

我想念与RN hot relad进行重新连接的技巧吗?

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

推荐答案

我在将任何Realm对象转换为可打印的字符串时遇到了一些麻烦;我总是像您一样得到 {} .我认为这可能与他们在GitHub上的此任务(未解决)有关.

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.

类似地,Realm的身份验证系统中存在一些错误.我正在尝试在我的应用程序中使用电子邮件/密码,Facebook和Google身份验证,但是目前看来它们都在Realm方面被破坏了.

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.

以下是他们在GitHub上的一些相关问题,您可以按照它们寻求解决方案.

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)

我没有有关JWT的任何信息,但鉴于其他身份验证问题,很有可能该问题不在您身边.我建议在他们的存储库中打开一个问题.

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.

这篇关于使用Realm.Credentials.jwt(token)进行身份验证时出现空对象用户,并且RN热重载导致Realm连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆