mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-17 10:55:12 +00:00
* get auth policy, fix increment from 0 * seo, accessibility * ngsw rem check for update * organize interceptors * toast i18n part1 * show loginname * use primary color * toast login handler, fix user session type * Update console/src/assets/i18n/de.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/de.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/de.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/en.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/index.html Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/en.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/en.json Co-authored-by: Florian Forster <[email protected]> Co-authored-by: Florian Forster <[email protected]>
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { AuthConfig } from 'angular-oauth2-oidc';
|
|
import { UserProfileView, UserSessionView } from 'src/app/proto/generated/auth_pb';
|
|
import { AuthUserService } from 'src/app/services/auth-user.service';
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
|
|
@Component({
|
|
selector: 'app-accounts-card',
|
|
templateUrl: './accounts-card.component.html',
|
|
styleUrls: ['./accounts-card.component.scss'],
|
|
})
|
|
export class AccountsCardComponent implements OnInit {
|
|
@Input() public profile!: UserProfileView.AsObject;
|
|
@Input() public iamuser: boolean = false;
|
|
|
|
@Output() public close: EventEmitter<void> = new EventEmitter();
|
|
public users: UserSessionView.AsObject[] = [];
|
|
public loadingUsers: boolean = false;
|
|
constructor(public authService: AuthService, private router: Router, private userService: AuthUserService) {
|
|
this.userService.getMyUserSessions().then(sessions => {
|
|
this.users = sessions.toObject().userSessionsList;
|
|
const index = this.users.findIndex(user => user.userName === this.profile.userName);
|
|
this.users.splice(index, 1);
|
|
|
|
this.loadingUsers = false;
|
|
}).catch(() => {
|
|
this.loadingUsers = false;
|
|
});
|
|
}
|
|
|
|
public ngOnInit(): void {
|
|
this.loadingUsers = true;
|
|
}
|
|
|
|
public editUserProfile(): void {
|
|
this.router.navigate(['user/me']);
|
|
this.close.emit();
|
|
}
|
|
|
|
public closeCard(element: HTMLElement): void {
|
|
if (!element.classList.contains('dontcloseonclick')) {
|
|
this.close.emit();
|
|
}
|
|
}
|
|
|
|
public selectAccount(loginHint?: string): void {
|
|
const configWithPrompt: Partial<AuthConfig> = {
|
|
customQueryParams: {
|
|
// prompt: 'select_account',
|
|
} as any,
|
|
};
|
|
if (loginHint) {
|
|
(configWithPrompt as any).customQueryParams['login_hint'] = loginHint;
|
|
}
|
|
this.authService.authenticate(configWithPrompt);
|
|
}
|
|
|
|
public selectNewAccount(): void {
|
|
const configWithPrompt: Partial<AuthConfig> = {
|
|
customQueryParams: {
|
|
prompt: 'login',
|
|
} as any,
|
|
};
|
|
this.authService.authenticate(configWithPrompt);
|
|
}
|
|
|
|
public logout(): void {
|
|
this.authService.signout();
|
|
this.close.emit();
|
|
}
|
|
}
|