【发布时间】:2018-06-24 13:33:57
【问题描述】:
我正在尝试按照本教程在我的 angular 5 应用程序中实现 auth0: https://toddmotto.com/angular-2-authentication
注册器工作正常,但是当我尝试登录时,我在控制台中得到以下信息:
这是我的身份验证服务:
import { Injectable } from '@angular/core';
// We want to avoid any 'name not found'
// warnings from TypeScript
declare var Auth0Lock: any;
@Injectable()
export class AuthService {
private lock
constructor() {
// These stuff should be exported into other files
this.lock = new Auth0Lock('id...',
'url...')
}
login() {
this.lock.show((error: string, profile: Object, id_token: string) => {
if (error) {
console.log(error);
} else {
console.log(profile)
localStorage.setItem('profile', JSON.stringify(profile));
localStorage.setItem('id_token', id_token);
}
});
}
logout() {
localStorage.removeItem('profile');
localStorage.removeItem('id_token');
}
}
有什么想法吗?
【问题讨论】: