Is there any way to get the current user on Angular using Angular + Asp.Net Boilerplate?
I know that I can get it on the API. But I want to send the object to the API with the current user id.
Is there any way to get the current user on Angular using Angular + Asp.Net Boilerplate?
I know that I can get it on the API. But I want to send the object to the API with the current user id.
On ABP it's different
Call
import { ConfigStateService } from '@abp/ng.core';
constructor(private configState: ConfigStateService)
And then
get currentUserId(): string {
return this.configState.getDeep('currentUser.id');
}
On angular declare a object of UserLoginInfoDto class. initialize the object value with this.appSession.user import UserLoginInfoDto class. For example:
userLogInInfo: UserLoginInfoDto;
and in Content or View Init
this.userLogInInfo = this.appSession.user;
UPDATE
I found a service where I can get user info.
@Injectable()
export class AppSessionService {
private _user: UserLoginInfoDto;
private _tenant: TenantLoginInfoDto;
private _application: ApplicationInfoDto;
constructor(
private _sessionService: SessionServiceProxy,
private _abpMultiTenancyService: AbpMultiTenancyService) {
}
get application(): ApplicationInfoDto {
return this._application;
}
get user(): UserLoginInfoDto {
return this._user;
}
get userId(): number {
return this.user ? this.user.id : null;
}
get tenant(): TenantLoginInfoDto {
return this._tenant;
}
get tenantId(): number {
return this.tenant ? this.tenant.id : null;
}
}