Starts in:
1 DAY
2 HRS
2 MIN
5 SEC
Starts in:
1 D
2 H
2 M
5 S

Activities of "alexander.nikonov"

I had additional experiment. Please have a look:

I've modified ngOnInit a bit:

this.oAuthService.events
  .pipe(
    filter(event => event?.type === 'logout'),
    tap(() => {
      this.unsubscriber$.next(null);
      this.unsubscriber$.complete();
      console.log('unsubscriber null!');
    }))
    .subscribe();

if (this.authService.isAuthenticated) {
  this.homeService.getNewsForHomePage()
    .pipe(tap(() => console.log('getNewsForHomePage still invoked')), takeUntil(this.unsubscriber$))
    .subscribe((newsResponse) => {
      this.newsForHomePage = newsResponse.items;
    });
  this.homeService.getUrlsForHomePage()
    .pipe(tap(() => console.log('getUrlsForHomePage still invoked')), takeUntil(this.unsubscriber$))
    .subscribe((newsUrlParameterResponse) => {
      this.urls = newsUrlParameterResponse.items;
      this.urlDigimedia = this.urls.filter(i => i.columnValue === 'DM')[0]?.stringValue;
      this.urlMasterData = this.urls.filter(i => i.columnValue === 'MD')[0]?.stringValue;
    });
}

I got 'unsubscriber null' message instantly after clicking "Logout" button. Despite this, shortly after, the method was still being invoked (getUrlsForHomePage matches '/api/ct/central-tool/parameters/values' API route). I cannot explain what's going on: The messages "getNewsForHomePage still invoked" and "getUrlsForHomePage still invoked" were never shown - obviosly because this.authService.isAuthenticated was false by the moment.

I thought it could have something to do with using guards. But even if I remove guard for Home page, the given API call is still invoked.

Hi

Now after logout i guess your api will also not get called, can you check please?

The API is still called though - after I click Logout, but before actual logging out is complete.

Hi,

you can directly redirect to login page by attaching you root page or home component a authguard.

Great! Thank you so much - this part is now resolved.

Thank you! Will be waiting. Also please suggest me how to logout directly to Identity Server Login box without visiting intermediate root page (Home page). I was trying to find the way (like editing SignOut URLs in Identity Server settings via admin UI page), but it did not bring me anywhere. I believe this used to work properly in some previous ABP version. Maybe we have unintentionally have changed some relevant setting.

Hi Anjali.

Don't want to upset you, but it's even worse now: the mentioned API call is still GET called after I press 'Logout'. But now after I'm doing this - I never gets logged out: after several chaning screens I'm eventually redirected to the root page, i.e. Home page...

Hi Anjali,

i've run debug again.

  1. when I click "Logout" on Home page - the onInit method IS get triggered with expected this.authService.isAuthenticated == false. But prior to that, I'm already getting 401 error request (sometimes - only this one request, sometimes - another one too): The "initiator" there is shown as "zone.js", later on it's getting cleared. So it's still looking confusing.

  2. our users complain about being redirected to landing page "Login" dialog, then - to Identity Server "Login" dialog (as shown on second screenshot). The request is to be redirected to the second "Login" dialog straight away... How to do that?

Hi Anjali.

I have to reopen this ticket, because without using this.routesService.refresh() it appeared, that sometimes just setting items to invisible is not enough: menu is still shown complete (suprisingly - sometimes it DOES work properly - when navigating to specific page menu is rebuilt according to invisibility of items). But using this.routesService.refresh() makes combineLatest trigger again. Could you please suggest the changed code - where the menu always refreshes properly, but there are no extra unnecessary invocations?

      init() {
        this.routesService.flat.filter(x => x.requiredPolicy && (x as any).data?.moduleId).forEach(x => x.invisible = true);
        this.routesService.refresh(); // HAVE TO USE IT to make invisibility to have effect
        combineLatest([this.configStateService.getDeep$('extraProperties.modulePermissionMap'), this.routesService.flat$.pipe(take(1))])
          .pipe
          (
            filter(([modulePermissionMap, route]) => Object.keys(modulePermissionMap).length > 0 && Object.keys(route).length > 0),
            takeUntil(this.destroy)
          )
          .subscribe(([modulePermissionMap, nonLazyLoadedRoute])  => {
            nonLazyLoadedRoute.filter(node => node.requiredPolicy).forEach((nonLazyRouteItem: ABP.Route) => {
              let moduleId = (nonLazyRouteItem as any).data?.moduleId;
              if (moduleId) {
                const moduleIdPolicyViolated = !modulePermissionMap[moduleId] || modulePermissionMap[moduleId] && !modulePermissionMap[moduleId].includes(nonLazyRouteItem.requiredPolicy as string);
                const ordinaryRolePolicyViolated = !modulePermissionMap['_ordinaryRole'] || modulePermissionMap['_ordinaryRole'] && !modulePermissionMap['_ordinaryRole'].includes(nonLazyRouteItem.requiredPolicy as string);
                if (!moduleIdPolicyViolated || !ordinaryRolePolicyViolated) {
                  nonLazyRouteItem.invisible = false;
                }
              }
            });
            this.routesService.refresh(); // HAVE TO USE IT to make invisibility to have effect, but combineLatest is called again... :(
        });
      }
      

UPDATE: this is a modified version - does it look ok?

      init() {
        this.routesService.flat.filter(x => x.requiredPolicy && (x as any).data?.moduleId).forEach(x => x.invisible = true);
        this.routesService.refresh();
        let routeStateBefore = JSON.stringify(this.routesService.flat, ['name', 'invisible']);
        combineLatest([this.configStateService.getDeep$('extraProperties.modulePermissionMap'), this.routesService.flat$.pipe(take(1))])
          .pipe
          (
            filter(([modulePermissionMap, route]) => Object.keys(modulePermissionMap).length > 0 && Object.keys(route).length > 0),
            takeUntil(this.destroy)
          )
          .subscribe(([modulePermissionMap, nonLazyLoadedRoute])  => {
            nonLazyLoadedRoute.filter(node => node.requiredPolicy).forEach((nonLazyRouteItem: ABP.Route) => {
              let moduleId = (nonLazyRouteItem as any).data?.moduleId;
              if (moduleId) {
                const moduleIdPolicyViolated = !modulePermissionMap[moduleId] || modulePermissionMap[moduleId] && !modulePermissionMap[moduleId].includes(nonLazyRouteItem.requiredPolicy as string);
                const ordinaryRolePolicyViolated = !modulePermissionMap['_ordinaryRole'] || modulePermissionMap['_ordinaryRole'] && !modulePermissionMap['_ordinaryRole'].includes(nonLazyRouteItem.requiredPolicy as string);
                if (!moduleIdPolicyViolated || !ordinaryRolePolicyViolated) {
                  nonLazyRouteItem.invisible = false;
                }
              }
            });
            let routeStateNow = JSON.stringify(this.routesService.flat, ['name', 'invisible']);
            if (routeStateNow !== routeStateBefore) {
              routeStateBefore = routeStateNow;
              this.routesService.refresh();
            }
          });
      }

Hi Anjali,

unfortunately, it did not help - still getting 401 on logout in one of two methods. Suprisingly, this method has another problem - it is for some reason invoked twice, even though in debug I just got it triggered once.

I'm attaching the Home module code - probably you will figure out what is wrong. It is actually not my code, so I am not sure I would be able to reply you all the questions. But I'm ready to assist in any possible way.

Thank you. Home page

Actually one more thing confuses me: after I do log out - I'm redirected to this page ("Home"): instead of this: So I need to click "Login" again to be redirected to the second dialog. But the routing in the app is the same as in test ABP app...

I've finally managed to resolve my issue. I will show my approach - probably this would come in handy for someone:

Actually two steps are needed:

  1. Create permission itself and add it as a child either to another custom permission or to the root permission node (in my case it is roleSubgroupPermissionDefinition):

     readModuleRolePermissionDefinition = roleSubgroupPermissionDefinition?.AddChild(readRoleName).WithProviders(ModulePermissionRoleValueProvider.ProviderName);
    
  2. Add the created permission to PermissionDefinitions collection of ABP static permission store:

     await (_staticPermissionDefinitionStore as IExtendedStaticPermissionDefinitionStore).AddPermissionDefinitionAsync(readModuleRolePermissionDefinition.Name, readModuleRolePermissionDefinition);
    

For this, i've extended ABP class with own methods. They are very simple - just to have access to PermissionDefinitions collection:

    public Task AddPermissionDefinitionAsync(string key, PermissionDefinition permissionDefinition)
    {
        if (!PermissionDefinitions.ContainsKey(key))
        {
            PermissionDefinitions.Add(key, permissionDefinition);
        }
        return Task.CompletedTask;
    }

Nothing more is needed - no refresh or something...

Thank you for your cooperation.

I already did this before. And I'm getting the error about missing custom permission definition group: All other permission definition groups are at place. When I do not override StaticPermissionDefinitionStore - the custom permission definition group is present as expected.

What do I need to adjust in MyStaticPermissionDefinitionStore to make the group available?

Showing 101 to 110 of 289 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06