@netgrif/components-core
Version:
Netgrif Application engine frontend core Angular library
76 lines (75 loc) • 3.98 kB
TypeScript
import { OnDestroy } from '@angular/core';
import { ConfigurationService } from "../../configuration/configuration.service";
import { Observable, ReplaySubject, Subscription } from 'rxjs';
import { ProcessRole } from '../../resources/interface/process-role';
import { User } from '../models/user';
import { Credentials } from '../../authentication/models/credentials';
import { AuthenticationService } from '../../authentication/services/authentication/authentication.service';
import { UserResourceService } from '../../resources/engine-endpoint/user-resource.service';
import { UserTransformer } from '../../authentication/models/user.transformer';
import { LoggerService } from '../../logger/services/logger.service';
import { SessionService } from '../../authentication/session/services/session.service';
import { AnonymousService } from '../../authentication/anonymous/anonymous.service';
import * as i0 from "@angular/core";
export declare class UserService implements OnDestroy {
protected _authService: AuthenticationService;
protected _userResource: UserResourceService;
protected _userTransform: UserTransformer;
protected _log: LoggerService;
protected _session: SessionService;
protected _anonymousService: AnonymousService;
protected _config: ConfigurationService;
protected _user: User;
protected _userChange$: ReplaySubject<User>;
protected _anonymousUserChange$: ReplaySubject<User>;
protected _loginCalled: boolean;
protected _subAuth: Subscription;
protected _subAnonym: Subscription;
private _publicLoadCalled;
readonly GLOBAL_ROLE_PREFIX = "global_";
constructor(_authService: AuthenticationService, _userResource: UserResourceService, _userTransform: UserTransformer, _log: LoggerService, _session: SessionService, _anonymousService: AnonymousService, _config: ConfigurationService);
get user(): User;
get user$(): Observable<User>;
get anonymousUser(): User;
get anonymousUser$(): Observable<User>;
ngOnDestroy(): void;
/**
* Check if user has specified authority.
* @param authority - If provided authority is array of authorities.
* Method make intersection of the provided authorities and user's authorities.
* If calculated intersection isn't empty returns true, otherwise false.
*/
hasAuthority(authority: Array<string> | string): boolean;
hasRole(role: ProcessRole): boolean;
/**
* Checks whether the user has role with a specific stringId
* @param roleStringId ID of the role we want to check
*/
hasRoleById(roleStringId: string): boolean;
/**
* Checks whether the user has a role with the specified identifier in a process with the specified identifier (any version),
* or if the role is global (with prefix 'global_').
* @param roleIdentifier identifier (import ID) of the role we want to check
* @param netIdentifier identifier (import ID) of the process the role is defined in
*/
hasRoleByIdentifier(roleIdentifier: string, netIdentifier: string): boolean;
/**
* Checks whether the user has role with the specified name in a process with the specified identifier (any version)
* @param roleName name of the role we want to check
* @param netIdentifier identifier (import ID) of the process the role is defined in
*/
hasRoleByName(roleName: string, netIdentifier: string): boolean;
login(credentials: Credentials): Observable<User>;
logout(): Observable<object>;
reload(): void;
protected emptyUser(): User;
protected loadUser(): void;
loadPublicUser(): void;
clearUser(): void;
isUserEmpty(user: User): boolean;
isCurrentUserEmpty(): boolean;
protected publishUserChange(): void;
protected publishAnonymousUserChange(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<UserService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<UserService>;
}