session - Firebase 3.0 session 持久性

标签 session firebase persistence firebase-authentication

在 firebase 3.0 中似乎不可能使用 session 持久性。

这在以前的版本中是可能的:
https://www.firebase.com/docs/web/guide/login/password.html

authWithPassword() takes an optional third parameter which is an object containing any of the following settings:

remember - String
If not specified - or set to default - sessions are persisted for as long as you have configured in the Login & Auth tab of your App Dashboard. To limit persistence to the lifetime of the current window, set this to sessionOnly. A value of none will not persist authentication data at all and will end authentication as soon as the page is closed.



在 3.0 版本中没有提到可选的第三个参数:
https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signInWithEmailAndPassword

signInWithEmailAndPassword(email, password)
returns firebase.Promise containing non-null firebase.User



此外,在新控制台 ( https://console.firebase.google.com/ ) 中,我找不到更改默认持久性的选项。

最佳答案

可能还值得一提的是,您需要等待 auth 状态解析。根据文档:

The recommended way to get the current user is by setting an observer on the Auth object:


firebase.auth().onAuthStateChanged(function(user) {
  if (user) {
    // User is signed in.
  } else {
    // No user is signed in.
  }
});

链接到此处的文档:https://firebase.google.com/docs/auth/web/manage-users

关于session - Firebase 3.0 session 持久性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37568644/

相关文章:

firebase - 为什么我无法更改 Firebase 引用的优先级(权限被拒绝)

node.js - Swift 和 Firebase 函数 : HTTPS authenticate the user

java - 多级层次结构的 Hibernate 混合继承策略

java - 从数据库自动创建实体

session - 在tomcat领域获取 session 属性

java - 如何删除不再有效的仪表

ionic-framework - 此环境不支持 FIRebase Google 身份验证操作

asp.net - ASP.NET 是在请求​​开始时从 SQL Server 传输所有 session 数据,还是仅在需要时传输?

PHP取消设置 session 变量

MySQL CASE EnumInt WHEN Varchar ELSE Int 返回为 BLOB - 如何转换为 Varchar?