【问题标题】:auth0 router doesn't trigger navigationauth0 路由器不触发导航
【发布时间】:2017-09-03 07:40:00
【问题描述】:

我将 Auth0 与 Angular 2 一起使用。我有以下登录代码,在身份验证后不会转到主页。

据我了解,auth0 不会进行重定向。它发送经过身份验证的事件,它应该在本地存储中创建一个项目,然后导航到主页。

@Injectable()
export class AuthService {

    lock = new Auth0Lock(this.config.clientID, this.config.domain, {
        auth: {

            responseType: 'token',
        }
    });

    constructor(private http: Http, private config: AppConfig, private router: Router) { 
        // Add callback for lock `authenticated` event
        this.lock.on('authenticated', (authResult) => {
            localStorage.setItem('id_token', authResult.idToken);
            console.log(localStorage);
            this.router.navigate(['home']);
        });
    }

【问题讨论】:

    标签: javascript angular auth0


    【解决方案1】:

    您可以尝试 location.replace('/home')location.replace('http://localhost:4200/home')

    【讨论】:

      猜你喜欢
      • 2012-06-26
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-06
      • 2020-02-12
      • 1970-01-01
      相关资源
      最近更新 更多