本文整理匯總了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();
}