Starts in:
0 DAY
20 HRS
15 MIN
0 SEC
Starts in:
0 D
20 H
15 M
0 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 November 20, 2024, 13:06