aspnetboilerplate / aspnetboilerplate

ASP.NET Boilerplate - Web Application Framework
https://aspnetboilerplate.com
MIT License
11.77k stars 3.79k forks source link

[Question] User Granted Permissions (front end) #5861

Closed worthy7 closed 3 years ago

worthy7 commented 3 years ago

Hi there, I have an angular app, that would refresh the users session (by sending a message in Signalr and having the sessionservice re-init) when permissions changed on the back end.

Did something change recently so that the users permissions are no longer stored on GetUserInfo, but instead on GetAll?

I removed the refresh when logging in (so that the app would be smoother). The session would reinit and it caused permissions etc to be updated client side. But now when people log in, they have no permissions until they refresh the page.

ryancyq commented 3 years ago

@worthy7 could you share from/to version of the template you observed the behavior change?

granted permissions has always been returned via /AbpUserConfiguration/GetAll for angular template.

worthy7 commented 3 years ago

Then perhaps it was just my misunderstanding. This is very confusing because I am sure that when our users "upgraded to premium" the screen would magically change to the premium version without a refresh, I specifically designed it like this - but that seems to be broken now because the "user refresh" is no longer updating permissions.

Is the GetAll call the ONLY time that permissions are updated? Is there perhaps something else I was using that he changed?

In terms of version, I did upgrade the front end abp-ng2-module package to 6.2 from ^5.1.1

Hmm... I am so sure that I did have the permissions updating, through angular, without having to refresh...

On Sat, 31 Oct 2020 at 02:16, Ryan Chang notifications@github.com wrote:

@worthy7 https://github.com/worthy7 could you share from/to version of the template you observed the behavior change?

granted permissions has always been returned via /AbpUserConfiguration/GetAll for angular template.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnetboilerplate/aspnetboilerplate/issues/5861#issuecomment-719683751, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEKWHZLAMCM4IZPFEY2PXDSNLYH5ANCNFSM4TEWBMLA .

worthy7 commented 3 years ago

Sorry for the daft question, It seems I did have some code which I have accidentally removed whilst trying to fix the way login worked:

    private getUserConfiguration(callback: () => void): JQueryPromise<any> {
        return abp.ajax({
            url: AppConsts.remoteServiceBaseUrl + '/AbpUserConfiguration/GetAll',
            method: 'GET',
            headers: {
                Authorization: 'Bearer ' + abp.auth.getToken(),
                '.AspNetCore.Culture': abp.utils.getCookieValue("Abp.Localization.CultureName"),
                'Abp.TenantId': abp.multiTenancy.getTenantIdCookie()
            }
        }).done(result => {
            $.extend(true, abp, result);
            abp.auth.grantedPermissions = result.auth.grantedPermissions;
            abp.clock.provider = this.getCurrentClockProvider(result.clock.provider);

            moment.locale(abp.localization.currentLanguage.name);

            if (abp.clock.provider.supportsMultipleTimezone) {
                moment.tz.setDefault(abp.timing.timeZoneInfo.iana.timeZoneId);
            }

            callback();
        });
    }

    private getCurrentClockProvider(currentProviderName: string): abp.timing.IClockProvider {
        if (currentProviderName === "unspecifiedClockProvider") {
            return abp.timing.unspecifiedClockProvider;
        }

        if (currentProviderName === "utcClockProvider") {
            return abp.timing.utcClockProvider;
        }

        return abp.timing.localClockProvider;
    }