add some overrides & keycloak token$
This commit is contained in:
parent
17d2e8c530
commit
ebaf1709b1
@ -8,8 +8,8 @@ export class NestedFilter extends Filter implements INestedFilter, IListable {
|
||||
disabled?: boolean;
|
||||
helpModeKey?: string;
|
||||
readonly children: Filter[];
|
||||
readonly skipTranslation?: boolean;
|
||||
readonly metadata?: Record<string, any>;
|
||||
override readonly skipTranslation?: boolean;
|
||||
override readonly metadata?: Record<string, any>;
|
||||
|
||||
constructor(nestedFilter: INestedFilter) {
|
||||
super(nestedFilter);
|
||||
|
||||
@ -51,7 +51,7 @@ export class DynamicInputComponent extends FormFieldComponent<DynamicInput> {
|
||||
readonly isNumber = computed(() => this.type() === InputTypes.NUMBER);
|
||||
readonly isText = computed(() => this.type() === InputTypes.TEXT);
|
||||
|
||||
writeValue(input: DynamicInput): void {
|
||||
override writeValue(input: DynamicInput): void {
|
||||
this.input.set(input);
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ export const KEYS = {
|
||||
export abstract class IqserUserPreferenceService extends GenericService<UserAttributes> {
|
||||
#userAttributes: UserAttributes = {};
|
||||
protected abstract readonly _devFeaturesEnabledKey: string;
|
||||
protected readonly _serviceName: string = 'tenant-user-management';
|
||||
protected override readonly _serviceName: string = 'tenant-user-management';
|
||||
|
||||
get userAttributes(): UserAttributes {
|
||||
return this.#userAttributes;
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
import { KeycloakEventType, KeycloakService } from 'keycloak-angular';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
import { filter, switchMap } from 'rxjs/operators';
|
||||
import { getConfig } from '../../services/iqser-config.service';
|
||||
import { log, shareLast } from '../../utils';
|
||||
import { UI_ROOT } from '../../utils/tokens';
|
||||
import { getKeycloakOptions } from '../keycloak-options';
|
||||
import { TenantsService } from './tenants.service';
|
||||
@ -13,6 +15,12 @@ export class KeycloakStatusService {
|
||||
readonly #tenantsService = inject(TenantsService);
|
||||
readonly #uiRoot = inject(UI_ROOT);
|
||||
readonly #logger = inject(NGXLogger);
|
||||
readonly token$ = this.#keycloakService.keycloakEvents$.pipe(
|
||||
log('[KEYCLOAK] New event:'),
|
||||
filter(event => event.type === KeycloakEventType.OnAuthSuccess || event.type === KeycloakEventType.OnAuthRefreshSuccess),
|
||||
switchMap(() => this.#keycloakService.getToken()),
|
||||
shareLast(),
|
||||
);
|
||||
|
||||
createLoginUrlAndExecute(username?: string | null) {
|
||||
const keycloakInstance = this.#keycloakService?.getKeycloakInstance();
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { inject, Injectable, signal } from '@angular/core';
|
||||
import dayjs from 'dayjs';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
import { List } from '../../utils';
|
||||
import { GenericService } from '../../services';
|
||||
import { Tenant, TenantDetails } from '../types';
|
||||
import { Observable } from 'rxjs';
|
||||
import { GenericService } from '../../services';
|
||||
import { List } from '../../utils';
|
||||
import { Tenant, TenantDetails } from '../types';
|
||||
|
||||
export interface IStoredTenantId {
|
||||
readonly tenantId: string;
|
||||
@ -28,7 +28,7 @@ export class TenantsService extends GenericService<Tenant> {
|
||||
};
|
||||
readonly #activeTenantId = signal('');
|
||||
protected readonly _defaultModelPath = 'tenants';
|
||||
protected readonly _serviceName: string = 'tenant-user-management';
|
||||
protected override readonly _serviceName: string = 'tenant-user-management';
|
||||
|
||||
get activeTenantId() {
|
||||
return this.#activeTenantId();
|
||||
|
||||
@ -4,7 +4,7 @@ import { escapeHtml } from '../utils';
|
||||
|
||||
@Injectable()
|
||||
export class IqserTranslateParser extends TranslateDefaultParser {
|
||||
interpolate(expr: any, params?: Record<string, unknown>) {
|
||||
override interpolate(expr: any, params?: Record<string, unknown>) {
|
||||
const entries = Object.entries(params ?? {});
|
||||
const escapedParams = entries.reduce((acc, [key, value]) => ({ ...acc, [key]: escapeHtml(value) }), {});
|
||||
return super.interpolate(expr, escapedParams);
|
||||
|
||||
@ -23,11 +23,11 @@ export abstract class IqserUserService<
|
||||
Interface extends IIqserUser = IIqserUser,
|
||||
Class extends IqserUser & Interface = IqserUser & Interface,
|
||||
> extends EntitiesService<Interface, Class> {
|
||||
readonly currentUser$: Observable<Class | undefined>;
|
||||
protected abstract readonly _defaultModelPath: string;
|
||||
readonly #uiRoot = inject(UI_ROOT);
|
||||
protected abstract override readonly _defaultModelPath: string;
|
||||
protected abstract readonly _permissionsFilter: (role: string) => boolean;
|
||||
protected abstract readonly _rolesFilter: (role: string) => boolean;
|
||||
protected abstract readonly _entityClass: new (entityInterface: Interface | KeycloakProfile, ...args: unknown[]) => Class;
|
||||
protected abstract override readonly _entityClass: new (entityInterface: Interface | KeycloakProfile, ...args: unknown[]) => Class;
|
||||
protected readonly _currentUser$ = new BehaviorSubject<Class | undefined>(undefined);
|
||||
protected readonly _toaster = inject(Toaster);
|
||||
protected readonly _keycloakService = inject(KeycloakService);
|
||||
@ -35,8 +35,8 @@ export abstract class IqserUserService<
|
||||
protected readonly _keycloakStatusService = inject(KeycloakStatusService);
|
||||
protected readonly _permissionsService = inject(IqserPermissionsService, { optional: true });
|
||||
protected readonly _rolesService = inject(IqserRolesService, { optional: true });
|
||||
protected readonly _serviceName: string = 'tenant-user-management';
|
||||
readonly #uiRoot = inject(UI_ROOT);
|
||||
protected override readonly _serviceName: string = 'tenant-user-management';
|
||||
readonly currentUser$: Observable<Class | undefined>;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@ -80,7 +80,7 @@ export abstract class IqserUserService<
|
||||
await this._keycloakService.login({ action: 'UPDATE_PASSWORD' });
|
||||
}
|
||||
|
||||
loadAll() {
|
||||
override loadAll() {
|
||||
return this.getAll().pipe(
|
||||
mapEach(user => new this._entityClass(user, user.roles, user.userId)),
|
||||
tap(users => this.setEntities(users)),
|
||||
@ -121,7 +121,7 @@ export abstract class IqserUserService<
|
||||
return this.find(userId)?.name;
|
||||
}
|
||||
|
||||
getAll(url = this._defaultModelPath): Observable<Interface[]> {
|
||||
override getAll(url = this._defaultModelPath): Observable<Interface[]> {
|
||||
return super.getAll(url, [{ key: 'refreshCache', value: true }]);
|
||||
}
|
||||
|
||||
@ -157,12 +157,12 @@ export abstract class IqserUserService<
|
||||
return this._post(body);
|
||||
}
|
||||
|
||||
delete(userIds: List) {
|
||||
override delete(userIds: List) {
|
||||
const queryParams = userIds.map<QueryParam>(userId => ({ key: 'userId', value: userId }));
|
||||
return super.delete(userIds, this._defaultModelPath, queryParams);
|
||||
}
|
||||
|
||||
find(id: string): Class | undefined {
|
||||
override find(id: string): Class | undefined {
|
||||
if (id?.toLowerCase() === 'system') {
|
||||
return this.newSystemUser();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user