Open Closed

Back to default tenant from other tenant #3610


0
abpfintranet-1 created

When I as admin click on "Login with this tenant" and enter to a new tenant environment, I want to put a button in my custom template, like the return button which ABP shows in entered tenant to return to default tenant. I want Angular codes to put in my button click to return to default tenant and the condition which I show this button in other tenant which admin entered to it from default tenant.

ABP Commercial version is 5.3.3 Angular version 14.0.3


2 Answer(s)
  • 0
    muhammedaltug created
    Support Team

    Hello

    You can use the following example

    import { ConfigStateService } from '@abp/ng.core';
    import { Component } from '@angular/core';
    import { map } from 'rxjs/operators';
    
    @Component({
      selector: 'app-your-component',
      template: '<div *ngIf="isImpersonatorLogin$ | async"></div>',
    })
    export class YourComponent {
        isImpersonatorLogin$ = this.configState.getDeep$('currentUser.impersonatorUserId').pipe(map(Boolean))
    
      constructor(
        private configState: ConfigStateService
      ) {}
    
    }
    
    
    
  • 0
    muhammedaltug created
    Support Team

    Also, you can use ImpersonationService for impersonation actions.

    import { ConfigStateService } from '@abp/ng.core';
    import { Component } from '@angular/core';
    import { map } from 'rxjs/operators';
    import { ImpersonationService } from '@volo/abp.commercial.ng.ui/config';
    
    @Component({
      selector: 'app-your-component',
      template: '<div *ngIf="isImpersonatorLogin$ | async" (click)="backToImpersonator()"></div>',
    })
    export class YourComponent {
        isImpersonatorLogin$ = this.configState.getDeep$('currentUser.impersonatorUserId').pipe(map(Boolean))
    
      constructor(
        private configState: ConfigStateService,
        private impersonationService: ImpersonationService,
      ) {}
      
      backToImpersonator() {
        this.impersonationService.impersonate({}).subscribe();
      }
    
    }