Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How I can use current user information in all components? #6698


User avatar
0
GSOFT created

Suppose I have a variable used to store current user, I use this variable to filter data. Where should I put the code below? And How can I use it across all components?

async getCurrentLoginInformations(): Promise<string>{
        let result = await this._sessionAppService.getCurrentLoginInformations().toPromise();
        this.userIdFilter = result.user.userName;
        if (this.userIdFilter == 'admin')
            {this.userIdFilter = '';}
        return this.userIdFilter;       
    }

2 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, currently app-session service has been injected in app-component-base.

    you can access current user info via this.appService.getUser() in your component.

  • User Avatar
    0
    GSOFT created

    Thank you, I solved it.