【发布时间】:2020-04-27 18:20:11
【问题描述】:
我正在查看 Firebase 身份验证文档 here,特别是此代码示例,用于创建会话的客户端代码:
firebase.auth().signInWithEmailAndPassword('user@example.com', 'password').then(user => {
// Get the user's ID token as it is needed to exchange for a session cookie.
return user.getIdToken().then(idToken = > {
// Session login endpoint is queried and the session cookie is set.
// CSRF protection should be taken into account.
// ...
const csrfToken = getCookie('csrfToken')
return postIdTokenToSessionLogin('/sessionLogin', idToken, csrfToken);
});
}).then(() => {
// A page redirect would suffice as the persistence is set to NONE.
return firebase.auth().signOut();
}).then(() => {
window.location.assign('/profile');
});
这里的第一部分很有意义——登录并创建一个会话。但是中间的then 调用signOut——什么?你为什么想这么做?在文档中此代码之前有一条注释:
成功后,应从客户端存储中清除状态。
不清楚该评论是否指的是signOut 调用。不太确定为什么要这样做,无论哪种方式......然后firebase认为用户已退出,但您的服务器有该用户的活动会话。
有人能对此有所了解吗?
【问题讨论】:
标签: javascript firebase firebase-authentication firebase-admin