Base solution for your next web application
Open Closed

AppPermissions.Pages_Administration_Languages_Edit and Default Language #10326


User avatar
0
cangunaydin created

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? v9.3.0
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .net core

Hello, Is it possible to change the default language for specific tenants in the application. When we upgrade our project to v9.3.0 from v8.1.0 the menu option has disappeared from the action button list in languages. So when i looked into it, there is an if condition in angular html page.

 <li>
                                                        <a href="javascript:;" class="dropdown-item"
                                                            *ngIf="'Pages.Administration.Languages.Edit' | permission"
                                                            (click)="setAsDefaultLanguage(record)">{{'SetAsDefaultLanguage' | localize}}</a>
                                                    </li>

and on the server side permissions has been stated if it is a multitenant application the permission is created for the host. in AppAuthorizationProvider.cs

var languages = administration.CreateChildPermission(AppPermissions.Pages_Administration_Languages, L("Languages"));
            languages.CreateChildPermission(AppPermissions.Pages_Administration_Languages_Create, L("CreatingNewLanguage"), multiTenancySides: _isMultiTenancyEnabled ? MultiTenancySides.Host : MultiTenancySides.Tenant);
            languages.CreateChildPermission(AppPermissions.Pages_Administration_Languages_Edit, L("EditingLanguage"), multiTenancySides: _isMultiTenancyEnabled ? MultiTenancySides.Host : MultiTenancySides.Tenant);
            languages.CreateChildPermission(AppPermissions.Pages_Administration_Languages_Delete, L("DeletingLanguages"), multiTenancySides: _isMultiTenancyEnabled ? MultiTenancySides.Host : MultiTenancySides.Tenant);
            languages.CreateChildPermission(AppPermissions.Pages_Administration_Languages_ChangeTexts, L("ChangingTexts"));

so the question is if this is by design with the new version? or is it a bug? and when i look at the application service for changing default language,

  public async Task SetDefaultLanguage(SetDefaultLanguageInput input)
        {
            await _applicationLanguageManager.SetDefaultLanguageAsync(
                AbpSession.TenantId,
               CultureHelper.GetCultureInfoByChecking(input.Name).Name
                );
        }

there is no permission restriction with abpauthorize? can you clarify this? Thank you for the assistance


4 Answer(s)
  • User Avatar
    0
    musa.demir created

    Hi @cangunaydin

    Here is the commit that make that changes. https://github.com/aspnetzero/aspnet-zero-core/commit/f19577b88825dc983d433ca5fde4031344a1f14e

    We implemented that to make the default language selection on a tenant basis. But as you can see it is stored in settings, and since settings are hierarchic by default, you can set a default value for that settings by using ChangeSettingForApplicationAsync. See https://aspnetboilerplate.com/Pages/Documents/Setting-Management

    The reason why _applicationLanguageManager.SetDefaultLanguageAsyncwork correctly works is because it uses the code I mentioned. See: https://github.com/aspnetboilerplate/aspnetboilerplate/blob/9483445a401c3bc6573be43616689c0f1d23f26e/src/Abp.Zero.Common/Localization/ApplicationLanguageManager.cs#L254-L265

  • User Avatar
    0
    cangunaydin created

    Hello @musa.demir probably i couldn't explain it well. If you log in as tenant user, you can not see the change default language action button since there is

                                                       <li>
                                                            <a href="javascript:;" class="dropdown-item"
                                                                *ngIf="'Pages.Administration.Languages.Edit' | permission"
                                                                (click)="setAsDefaultLanguage(record)">{{'SetAsDefaultLanguage' | localize}}</a>
                                                        </li>
    

    above code block. If you look at *ngIf condition since it is a multitenant application, there is no permission defined for the tenant with the permission 'Pages.Administration.Languages.Edit'.

    https://github.com/aspnetzero/aspnet-zero-core/commit/f19577b88825dc983d433ca5fde4031344a1f14e

    as i see it here, if it is multitenant application Pages.Administration.Languages.Edit is defined on host not on tenant. so this button will not appear. am i missing sth over here?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @cangunaydin

    You are right about this. Maybe, it will be better to define a new permission for this because Tenants are not allowed to edit the languages when multi tenancy is enabled (this is by design) but they should be able to set the default language.

    Could you create an issue about this on GitHub ?

    Thanks

  • User Avatar
    0
    cangunaydin created

    Hello @ismcagdas here i created the issue on github you can find the link here. https://github.com/aspnetzero/aspnet-zero-core/issues/3933