1
我正在使用Auth0和Angular 2.我有以下登錄代碼,認證後沒有進入主頁。auth0路由器不會觸發導航
據我瞭解,auth0不會做重定向。它發送已認證的事件,並且它應該在localstorage中創建一個項目,然後導航到主頁。
@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']);
});
}