本文整理汇总了TypeScript中oidc-client.UserManager类的典型用法代码示例。如果您正苦于以下问题:TypeScript UserManager类的具体用法?TypeScript UserManager怎么用?TypeScript UserManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserManager类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setupUserManager
setupUserManager(stsAuthroity: string) {
const config: UserManagerSettings = {
authority: stsAuthroity,
client_id: 'spa-client',
redirect_uri: `${location.origin}/login-redirect.html`,
scope: 'openid spa-api profile offline_access',
response_type: 'id_token token',
post_logout_redirect_uri: `${location.origin}?postLogout=true`,
userStore: new WebStorageStateStore({ store: window.localStorage }),
automaticSilentRenew: true,
silent_redirect_uri: `${location.origin}/silent-renew.html`
};
this.userManager = new UserManager(config);
this.userManager.getUser().then(user => {
if (user && !user.expired) {
this.user = user;
// this.loadSecurityContext();
}
});
this.userManager.events.addUserLoaded(args => {
this.userManager.getUser().then(user => {
this.user = user;
// this.loadSecurityContext();
});
});
}
示例2: loginCallback
/**
* 登录回调
* @param options OpenId Connect认证登录回调配置
*/
async loginCallback(options: IOidcLoginCallbackOptions = null) {
options = options || {};
let user = await this.manager.signinRedirectCallback();
if (this.isAuthenticated(user)) {
this.loginSuccess(options, user);
return;
}
this.loginFail(options);
}
示例3: login
login(): Promise<any> {
return this.userManager.signinRedirect();
// this.dataService.post(this.userManager.settings.authority + '/connect/token', {
// grant_type: 'password',
// scope: 'openid profile aspnetcorespa-api offline_access roles',
// username: 'admin@admin.com',
// password: 'P@ssw0rd!',
// client_id: 'spa-client'
// }).subscribe(res => {
// console.log(res);
// });
}
示例4:
this.userManager.events.addUserLoaded(args => {
this.userManager.getUser().then(user => {
this.user = user;
// this.loadSecurityContext();
});
});
示例5: signoutRedirectCallback
signoutRedirectCallback(): Promise<any> {
return this.userManager.signoutRedirectCallback();
}
示例6: logout
logout(): any {
return this.userManager.signoutRedirect();
}
示例7: logout
/**
* 注销,重定向到认证服务进行登出操作
*/
logout() {
this.manager.signoutRedirect();
}
示例8: getUser
/**
* 获取用户信息
*/
getUser() {
return this.manager.getUser();
}
示例9: login
/**
* 登录,重定向到认证服务进行登录操作
*/
login() {
this.manager.signinRedirect();
}