Open Closed

Execute method after authenticated in angular client #6633


User avatar
0
pablo@ccalp.net created
  • ABP Framework version: v7.4.x
  • UI Type: Angular
  • Database System: EF Core (SQL Server)

I have created my own custom configuration service and added it to the app.module as a provider:

{
  provide: APP_INITIALIZER,
  useFactory: configurationFactory,
  deps: [ConfigurationService, ConfigStateService],
  multi: true,
},

There are configuration properties that I need before authentication and after authentication, how can I call my configuration service after the user has authenticated to refresh the configuration properties?

I see this being done already by the abp framework, how can I achieve the same?

Thanks.


3 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello,

    I am not exactly sure but I think this might help you.

    try to call your method inside below code in app.component.ts

    export class AppComponent {
      constructor(private authService:AuthService)   { }
       
      ngOnInit(): void {
      
       if(this.authService.isAuthenticated){
        console.log('logged in');
        //you can call your method here for refreshing the configuration properties
       }
    }
    }
    

    thanks

  • User Avatar
    0
    pablo@ccalp.net created

    Yeah, that's what I have, not sure if there was another way. Do you know how it is handled by the framework, is there any source code I can reference?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Maybe you can consider this: https://docs.abp.io/en/abp/latest/UI/Angular/Config-State-Service#set-state

    import {AbpApplicationConfigurationService, ConfigStateService} from '@abp/ng.core';
    
    constructor(private abpApplicationConfigurationService: AbpApplicationConfigurationService, private config: ConfigStateService) {
      this.abpApplicationConfigurationService.get().subscribe(config => {
        //you can call your method here for refreshing the configuration properties
      })
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38