首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >即使在登录角之后,直接点击url仍然需要再次登录页面。

即使在登录角之后,直接点击url仍然需要再次登录页面。
EN

Stack Overflow用户
提问于 2018-07-11 02:44:20
回答 3查看 2K关注 0票数 0

火基地认证是集成在一个角应用程序。即使登录到应用程序,点击一个url或路由直接在一个新的选项卡或浏览器的同一选项卡,铬,例如http://localhost:4200/landing再次进入登录页面。

如果登录页面已经登录,是否有方法不跳过登录页?

复制步骤

  1. ng在角CLI项目中服务,带我到http://localhost:4200/login
  2. 登录后需要登录到http://localhost:4200/landing
  3. 打开一个新选项卡或在现有的选项卡类型中,http://localhost:4200/landing点击enter

Expected:它停留在http://localhost:4200/landing

实际:它可以追溯到http://localhost:4200/login

EN

Stack Overflow用户

发布于 2018-07-13 03:20:51

我认为需要在下面进行修改。

代码语言:javascript
复制
 constructor(private _firebaseAuth: AngularFireAuth, private router: Router) {
    this.user = _firebaseAuth.authState;
    this.user.subscribe(
      (user) => {
        if (user) {
          this.userDetails = user;              
// Set the UserId
           localStorage.setItem('userId', user.uid);
        } else {
          this.userDetails = null;
        }
      }
    );
  }


  isLoggedIn() {

    if (this.userDetails == null) {
// Check the UserId
      if (localStorage.getItem('userId')) {
              return true;
      }
      return false;

    } else {
      return true;
    }
  }
票数 0
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51276498

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档