微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Firebase邀请已弃用使用vue.js和firebase设置用户邀请系统?

如何解决Firebase邀请已弃用使用vue.js和firebase设置用户邀请系统?

自从Firebase被弃用的Firebase邀请以来,使用vue + firebase创建安全邀请系统的最佳方法是什么?

在firebase身份验证的基础上,让我们假设我们有2个firestore表:

  • package rscope; import io.micronaut.http.client.RxHttpClient; import io.micronaut.http.client.annotation.Client; import io.micronaut.test.annotation.MicronautTest; import org.junit.jupiter.api.Test; import javax.inject.Inject; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @MicronautTest public class DemoControllerTest { @Inject @Client("/") RxHttpClient client; @Test public void testIndex() throws Exception { // these will contain the identity of the the DemoBean used to handle these requests String firstResponse = client.toBlocking().retrieve("/doit"); String secondResponse = client.toBlocking().retrieve("/doit"); assertTrue(firstResponse.matches("^Bean identity: \\d*$")); assertTrue(secondResponse.matches("^Bean identity: \\d*$")); // if you modify DemoBean to be @Singleton instead of // @RequestScope,this will fail because the same instance // will be used for both requests assertNotEquals(firstResponse,secondResponse); } } 包含用户ID和特定于项目的数据
  • users,其中每个集合都包含项目特定的数据和角色图,将firebase用户ID映射到其权限,例如。 projects

然后我们可以在firestore中设置规则,以便只有在字典中具有正确角色的经过身份验证的用户才能读取/写入{"rf276ft87gsa7vgwv":"owner"}集合中的给定文档。

在我看来,假设一切都在客户端运行,则无法安全地实施邀请系统。特别是,必须将新用户插入projects表中,这意味着任何已登录用户都将对任何项目具有编辑权限。

我看到的唯一选项似乎是一种解决方法:作为登录的项目所有者,使用fb.auth.createuserWithEmailAndPassword()创建用于邀请电子邮件的帐户,然后使用密码恢复。

解决方法

从Firebase邀请迁移到具有自定义共享的动态链接 documentation中所述,尽管邀请将被终止,但您仍然可以使用Firebase Dynamic Links真正有力量的邀请者:

Firebase邀请已弃用。从2020年1月24日起,我们将停止对Firebase邀请的支持。您将可以将Firebase Dynamic Links与自定义共享解决方案一起使用。

因此,唯一可以重建邀请的方法就是构建自定义sharing solution,下面是一个如何在链接上执行该示例的示例:

类似于以下示例的方法应该在这里起作用(建议您在自己的代码中使用常量字符串资源):

<input type="range" oninput="console.log(this.value)">

更多示例here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。