Search code examples
asp.net-boilerplate

ABP - How does abp.auth being evaluated when starting a project?


I added a side-bar menu and maybe twisted a little, somehow the abp.auth isn't working anymore.

I checked the abp.js, all I found is

abp.auth = abp.auth || {};
abp.auth.allPermissions = abp.auth.allPermissions || {};

So where does abp.auth or abp get the value in the first place? I checked the role application service, no breakpoint is entered. Then how can I trace this? Is it done inside the ABP framework? If so , how can I debug the abp.dll or whatever abp.XXX.dll in the template?

Many thanks!


Solution

  • abp.auth is initialized in ~/lib/abp-web-resources/Abp/Framework/scripts/abp.js.

    That's included in _Layout.cshtml by default:

    <environment names="Development">
        <script src="~/lib/abp-web-resources/Abp/Framework/scripts/abp.js" asp-append-version="true"></script>
    </environment>
    
    <environment names="Staging,Production">
        <script src="~/view-resources/Views/_Bundles/shared-layout.min.js" asp-append-version="true"></script>
    </environment>
    

    Since it's a JavaScript library and not a .dll, it can be updated in package.json using yarn/npm.

    abp = abp || {}. So where does the abp at the right come from?

    It doesn't necessarily come from anywhere. It's done like this so that you can define abp and add your properties to the object even before abp.js loads, and this avoids replacing it.

    Where does abp.auth get its value then?

    abp.auth is just a JavaScript object. If you mean the allPermissions property, see #2569.
    It's populated in AuthorizationScriptManager.

    how to debug this library?

    To enable debugging, change Visual Studio (2017+) Debugging options like in the docs:

    • Uncheck "Enable Just My Code"
    • Check "Enable source server support"
    • Check "Enable source link support"