Ends in:
2 DAYS
14 HRS
21 MIN
11 SEC
Ends in:
2 D
14 H
21 M
11 S
Open Closed

Back to default tenant from other tenant #3610


User avatar
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)
  • User Avatar
    0
    muhammedaltug created

    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
      ) {}
    
    }
    
    
    
  • User Avatar
    0
    muhammedaltug created

    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();
      }
    
    }
    
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 02, 2024, 12:35