我正在尝试建立一个登录页面。在用户正确登录之后,我想退出index.html页面并重定向到我的portfolio.html页面。firebase.auth().onAuthStateChanged(user => { window.location = 'portfolio.html'; // No user is signed in.
// window.location
我已经实现了用于登录的firebase身份验证,并且我知道如何使用onAuthChangeState。问题是我现在正试图找到一种方法来阻止用户在没有登录页面的情况下访问其他页面。我希望有一些类似于php中的“会话或令牌”,作为用户访问页面的关键字。注意!我没有使用php,因为我也在使用firebase作为托管我的站点的一种方式。顺便说一句,我看到的大多数源代码只使用一个页面,并且使用了很多style.display = "none or block",我不想走这条路,因为我喜欢更有条理