Starts in:
2 DAYS
0 HR
56 MIN
14 SEC
Starts in:
2 D
0 H
56 M
14 S

Activities of "lalitChougule"

Hi cotur,

I was partially achieve your solution. But I have hit a dead end while seeding Roles

My Code :

 public class IdentityRolesDataSeedContributor : IDataSeedContributor, ITransientDependency
    {
        private readonly IRepository<IdentityRole> _identityRoleRepository;

        public IdentityRolesDataSeedContributor(IRepository<IdentityRole> identityRoleRepository)
        {
            _identityRoleRepository = identityRoleRepository;
        }

        public async Task SeedAsync(DataSeedContext context)
        {
            await _identityRoleRepository.InsertAsync(new IdentityRole(
                id: Guid.Parse("60353FF7-0F81-4DD5-AC1F-6F9559037720"),
                name: "RoleAbc",
                tenantId: Guid.Parse("d1be844b-d3a2-031a-f036-39f5d4380239")));
        }
    }

Error while unit testing :

---------- Starting test run ----------
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.2+2d84eb3141 (64-bit .NET Core 3.1.13)
[xUnit.net 00:00:02.63]   Starting:    SCV.Litmus.Application.Tests
[xUnit.net 00:00:15.39]     SCV.Litmus.LitmusIdentity.LitmusIdentityUserApplicationTests.CreateAsync [FAIL]
[xUnit.net 00:00:15.39]       System.InvalidOperationException : Role ROLEABC does not exist!
[xUnit.net 00:00:15.39]       Stack Trace:
[xUnit.net 00:00:15.39]            at Volo.Abp.Identity.IdentityUserStore.AddToRoleAsync(IdentityUser user, String normalizedRoleName, CancellationToken cancellationToken)
[xUnit.net 00:00:15.39]            at Microsoft.AspNetCore.Identity.UserManager`1.AddToRolesAsync(TUser user, IEnumerable`1 roles)
[xUnit.net 00:00:15.39]            at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
[xUnit.net 00:00:15.39]            at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
[xUnit.net 00:00:15.39]            at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
[xUnit.net 00:00:15.39]            at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
[xUnit.net 00:00:15.39]            at Volo.Abp.Identity.IdentityUserManager.SetRolesAsync(IdentityUser user, IEnumerable`1 roleNames)
[xUnit.net 00:00:15.39]            at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
[xUnit.net 00:00:15.39]            at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
[xUnit.net 00:00:15.39]            at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
[xUnit.net 00:00:15.39]            at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
[xUnit.net 00:00:15.39]            at Volo.Abp.Identity.IdentityUserAppService.UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input)
[xUnit.net 00:00:15.40]         D:\Litmus\Projects\ap-ar-dashboard\SCV.Litmus\aspnet-core\modules\litmus-core\src\SCV.Litmus.Application\LitmusIdentity\LitmusIdentityUserAppService.cs(106,0): at SCV.Litmus.LitmusIdentity.LitmusIdentityUserAppService.CreateAsync(IdentityUserCreateDto input)
[xUnit.net 00:00:15.40]            at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
[xUnit.net 00:00:15.40]            at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
[xUnit.net 00:00:15.40]            at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
[xUnit.net 00:00:15.40]            at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
[xUnit.net 00:00:15.40]            at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
[xUnit.net 00:00:15.40]            at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
[xUnit.net 00:00:15.40]            at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
[xUnit.net 00:00:15.40]            at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
[xUnit.net 00:00:15.40]            at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
[xUnit.net 00:00:15.40]            at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
[xUnit.net 00:00:15.40]            at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
[xUnit.net 00:00:15.40]            at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
[xUnit.net 00:00:15.40]            at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
[xUnit.net 00:00:15.40]            at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
[xUnit.net 00:00:15.40]            at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
[xUnit.net 00:00:15.40]            at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
[xUnit.net 00:00:15.40]         D:\Litmus\Projects\ap-ar-dashboard\SCV.Litmus\aspnet-core\modules\litmus-core\test\SCV.Litmus.Application.Tests\LitmusIdentity\LitmusIdentityUserApplicationTests.cs(89,0): at SCV.Litmus.LitmusIdentity.LitmusIdentityUserApplicationTests.CreateAsync()
[xUnit.net 00:00:15.40]         --- End of stack trace from previous location where exception was thrown ---
[xUnit.net 00:00:15.42]   Finished:    SCV.Litmus.Application.Tests
========== Test run finished: 1 Tests run in 17.2 sec (0 Passed, 1 Failed, 0 Skipped) ==========

Can you tell me what I am doing wrong here ?

  • ABP Framework version: v3.0.4
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

Hi,

I was trying to mock IdentityUserManager

Error :

Can not instantiate proxy of class: Volo.Abp.Identity.IdentityUserManager.
Could not find a parameterless constructor.

StackTrace :

   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxyInstance(Type proxyType, List`1 proxyArguments, Type classToProxy, Object[] constructorArguments)
   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.CreateProxyUsingCastleProxyGenerator(Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments, IInterceptor[] interceptors, ProxyGenerationOptions proxyGenerationOptions)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.GenerateTypeProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.GenerateProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
   at NSubstitute.Core.SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments, Boolean callBaseByDefault)
   at NSubstitute.Core.SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments)
   at NSubstitute.Substitute.For(Type[] typesToProxy, Object[] constructorArguments)
   at NSubstitute.Substitute.For[T](Object[] constructorArguments)
   at SCV.Litmus.LitmusIdentity.LitmusUserInfoApplicationTests.AfterAddApplication(IServiceCollection services) in D:\Litmus\Projects\ap-ar-dashboard\SCV.Litmus\aspnet-core\modules\litmus-core\test\SCV.Litmus.Application.Tests\LitmusIdentity\LitmusUserInfoApplicationTests.cs:line 26
   at Volo.Abp.Testing.AbpIntegratedTest`1..ctor()
   at SCV.Litmus.LitmusTestBase`1..ctor()
   at SCV.Litmus.LitmusApplicationTestBase..ctor()
   at SCV.Litmus.LitmusIdentity.LitmusUserInfoApplicationTests..ctor() in D:\Litmus\Projects\ap-ar-dashboard\SCV.Litmus\aspnet-core\modules\litmus-core\test\SCV.Litmus.Application.Tests\LitmusIdentity\LitmusUserInfoApplicationTests.cs:line 19

My Code :

public class LitmusUserInfoApplicationTests : LitmusApplicationTestBase
    {
        private readonly ILitmusUserInfoAppService _litmusUserInfoAppService;

        private IdentityUserManager _identityUserManager;

        public LitmusUserInfoApplicationTests()
        {
            _litmusUserInfoAppService = GetRequiredService&lt;ILitmusUserInfoAppService&gt;();
        }

        protected override void AfterAddApplication(IServiceCollection services)
        {
            _identityUserManager = Substitute.For&lt;IdentityUserManager&gt;();
            services.AddSingleton(_identityUserManager);
        }

        [Fact]
        public async Task GetSellerQuestionnaireForMakerCheckAsync()
        {
            _identityUserManager.FindByIdAsync("39faa1bb-6509-6a7d-b17f-0deee2cf47db")
                .Returns(Task.FromResult(JsonConvert.DeserializeObject&lt;IdentityUser&gt;(@"{
                      'TenantId': 'd1be844b-d3a2-031a-f036-39f5d4380239',
                      'UserName': 'Seller.Admin',
                      'NormalizedUserName': 'SELLER.ADMIN',
                      'Name': 'Seller',
                      'Surname': 'Admin',
                      'Email': 'seller.admin@ness.com',
                      'NormalizedEmail': 'LALIT.CHOUGULE@NESS.COM',
                      'EmailConfirmed': false,
                      'PasswordHash': 'AQAAAAEAACcQAAAAEOK/7B0qge7madNnCVW5zGiVxa7sgIYc7XIKR/wG+fuDFn2g28hDGmd/i34RV/Rc8Q==',
                      'SecurityStamp': 'CUICLIBP3N5Z7NV52SKWF2MHBRIGDEPZ',
                      'PhoneNumber': null,
                      'PhoneNumberConfirmed': false,
                      'TwoFactorEnabled': true,
                      'LockoutEnd': null,
                      'LockoutEnabled': true,
                      'AccessFailedCount': 0,
                      'Roles': [
                        {
                          'TenantId': 'd1be844b-d3a2-031a-f036-39f5d4380239',
                          'UserId': '39fd4aa9-8553-35c0-4312-0d7b5f01b810',
                          'RoleId': '39fc43a0-e722-2bc3-7d24-9cc6992ccd3a'
                        }
                      ],
                      'Claims': [],
                      'Logins': [],
                      'Tokens': [],
                      'OrganizationUnits': [],
                      'IsDeleted': false,
                      'DeleterId': null,
                      'DeletionTime': null,
                      'LastModificationTime': '2021-06-23T16:22:02.440744',
                      'LastModifierId': null,
                      'CreationTime': '2021-06-23T16:18:53.936857',
                      'CreatorId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                      'ExtraProperties': {
                        'PasswordSetDate': '2021-09-21T10:50:14.4543311Z',
                        'HaveOptedMakerChecker': true
                      },
                      'ConcurrencyStamp': '5224e087605a4f498a9684556b5506dc',
                      'Id': '39fd4aa9-8553-35c0-4312-0d7b5f01b810'
                    }")));

            var mock_sellerRequesterUsers = @"[
              {
                'TenantId': 'd1be844b-d3a2-031a-f036-39f5d4380239',
                'UserName': 'Seller.Requester',
                'NormalizedUserName': 'SELLER.REQUESTER',
                'Name': 'Seller',
                'Surname': 'Requester',
                'Email': 'Kaustubh.Kale@ness.com',
                'NormalizedEmail': 'KAUSTUBH.KALE@NESS.COM',
                'EmailConfirmed': false,
                'PasswordHash': 'AQAAAAEAACcQAAAAEFCPsMT+tOATxKorhUkndGa1/k3SOjnx3+emm2sWafeYlVvcnDFnSeP0k5uXlgYJwA==',
                'SecurityStamp': 'NUUY6ROI2NTZ7UBM2FBDHZBKP5UPXS7B',
                'PhoneNumber': null,
                'PhoneNumberConfirmed': false,
                'TwoFactorEnabled': true,
                'LockoutEnd': null,
                'LockoutEnabled': true,
                'AccessFailedCount': 0,
                'Roles': null,
                'Claims': null,
                'Logins': null,
                'Tokens': null,
                'OrganizationUnits': null,
                'IsDeleted': false,
                'DeleterId': null,
                'DeletionTime': null,
                'LastModificationTime': '2021-06-23T16:30:40.180889',
                'LastModifierId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                'CreationTime': '2021-06-23T16:30:29.23093',
                'CreatorId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                'ExtraProperties': {
                  'PasswordSetDate': '2021-09-21T11:00:28.4022237Z',
                  'HaveOptedMakerChecker': false
                },
                'ConcurrencyStamp': '0b7b68128a81401fbc6fa3f91e36b3f3',
                'Id': '39fd4ab4-2271-7518-4964-a131224f8919'
              }
            ]";

            _identityUserManager.GetUsersInRoleAsync("SellerRequester")
                .Returns(Task.FromResult(JsonConvert.DeserializeObject&lt;IList&lt;IdentityUser&gt;>(mock_sellerRequesterUsers)));

            var mock_sellerApproverUsers = @"[
              {
                'TenantId': 'd1be844b-d3a2-031a-f036-39f5d4380239',
                'UserName': 'Seller.Approver',
                'NormalizedUserName': 'SELLER.APPROVER',
                'Name': 'Seller',
                'Surname': 'Approver',
                'Email': 'Yaduraj.Shakti@ness.com',
                'NormalizedEmail': 'YADURAJ.SHAKTI@NESS.COM',
                'EmailConfirmed': false,
                'PasswordHash': 'AQAAAAEAACcQAAAAEJkl+HrzdX1HQPWcLTvhmgtiibs2F4pX4avyk4UxK6iHFSCa5Ca4/VyNxVgyY47xIA==',
                'SecurityStamp': 'TUOGMEIA2RJSFMXCKARFLZO2XSK2QWCA',
                'PhoneNumber': null,
                'PhoneNumberConfirmed': false,
                'TwoFactorEnabled': true,
                'LockoutEnd': null,
                'LockoutEnabled': true,
                'AccessFailedCount': 0,
                'Roles': null,
                'Claims': null,
                'Logins': null,
                'Tokens': null,
                'OrganizationUnits': null,
                'IsDeleted': false,
                'DeleterId': null,
                'DeletionTime': null,
                'LastModificationTime': '2021-06-23T16:29:45.804466',
                'LastModifierId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                'CreationTime': '2021-06-23T16:29:33.925747',
                'CreatorId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                'ExtraProperties': {
                  'PasswordSetDate': '2021-09-21T10:59:32.8141291Z',
                  'HaveOptedMakerChecker': false
                },
                'ConcurrencyStamp': '7d9f64db3fa74b2b827940360d2b5185',
                'Id': '39fd4ab3-494d-9f88-56ac-e9b402130a4d'
              }
            ]";

            _identityUserManager.GetUsersInRoleAsync("SellerApprover")
               .Returns(Task.FromResult(JsonConvert.DeserializeObject&lt;IList&lt;IdentityUser&gt;>(mock_sellerApproverUsers)));

            var result = await _litmusUserInfoAppService.GetSellerQuestionnaireInfoAsync();
        }
    }

How do I mock IdentityUserManager ?

Can we have a session ? May be you can figure it out if you have a look ? It's bit urgent as my app is about to go live in few days.

hi @lalitChougule

How can I reproduce your problem?

I am not sure how its happening in my project. May be we can connect and you can have a look.

hi Please share these info.

  • ABP Framework version: vX.X.X
  • UI type: Angular / MVC / Blazor
  • DB provider: EF Core / MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): yes / no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

ABP Framework version: v3.0.4 UI type: Angular DB provider: EF Core Tiered (MVC) or Identity Server Separated (Angular): no / yes Exception message and stack trace: N.A Steps to reproduce the issue: N.A

Hi @muhammedaltug,

Thanks to answer my queries. I have few more requirement, and few previously unanswered questions and its related to same topic so posting it here itself.

  1. To hide password and username field from user creation form, Can it be done only by replacing the whole component or there is any other way around ? I don't want to replace whole component just for this small change.
  2. Just like what we do on backend i.e. override only particular method of service , can we do same for user.component ? i.e. in angular component ?
  3. Requirement : Once my user is created I want to redirect the user to my custom page.

Can all the above requirements can be done without replacing user.component ? If yes please guide me.

Thanks in advance !!!

Hi,

Why you can't access IIdentityRoleRepository? Can you explain the structure of your project

I think we are trying to access it in Application.Contracts thatz why its not accessible.

My Project structure

Gateway
	MainProject.HttpApi.Host
Microservices
	ProjectA.HttpApi.Host
	ProjectB.HttpApi.Host
	ProjectC.HttpApi.Host -- IdentityServer
	ProjectD.HttpApi.Host
Module
	ProjectA
		scr
			ProjectA.Application
			ProjectA.Application.Contracts
			ProjectA.Domain
			ProjectA.Domain.Shared
			ProjectA.EntityFrameworkCore
			ProjectA.HttpApi
			ProjectA.HttpApiClient
		test
			ProjectA.Application.Tests
			ProjectA.Domain.Tests
			ProjectA.EntityFrameworkCore.Tests
			ProjectA.HttpApiClient.ConsoleTestApp
			ProjectA.TestBase
	ProjectB
		src
			ProjectB.Application
			ProjectB.Application.Contracts
			ProjectB.Domain
			ProjectB.Domain.Shared
			ProjectB.EntityFrameworkCore
			ProjectB.HttpApi
			ProjectB.HttpApiClient
		test
			ProjectB.Application.Tests
			ProjectB.Domain.Tests
			ProjectB.EntityFrameworkCore.Tests
			ProjectB.HttpApiClient.ConsoleTestApp
			ProjectB.TestBase
	ProjectC
		src
			ProjectC.Application
			ProjectC.Application.Contracts
			ProjectC.Domain
			ProjectC.Domain.Shared
			ProjectC.EntityFrameworkCore
			ProjectC.HttpApi
			ProjectC.HttpApiClient
		test
			ProjectC.Application.Tests
			ProjectC.Domain.Tests
			ProjectC.EntityFrameworkCore.Tests
			ProjectC.HttpApiClient.ConsoleTestApp
			ProjectC.TestBase
	ProjectD
		src
			ProjectD.Application
			ProjectD.Application.Contracts
			ProjectD.Domain
			ProjectD.Domain.Shared
			ProjectD.EntityFrameworkCore
			ProjectD.HttpApi
			ProjectD.HttpApiClient
		test
			ProjectD.Application.Tests
			ProjectD.Domain.Tests
			ProjectD.EntityFrameworkCore.Tests
			ProjectD.HttpApiClient.ConsoleTestApp
			ProjectD.TestBase

The code which I am trying to do is in Module of Gateway project.

HI

It depends on where your dynamic permissions are stored. If your application is a monolithic application, you can consider try to inject the repository.

In short, don't call application services, because this will cause an infinite loop.

Ok I got your point. What are the other ways of access roles ? I dont want to access permissions. I want to access all roles.

I am not able to access IIdentityRoleRepository as well as IdentityRoleManager in the above code block.

hi

The application service will try to get all permissions when you call the its method, it will be an infinite loop.

So do not call application service in the Define method.

You can get dynamic permissions through other ways. Async methods are preferred.

Please provide sample code, What are the other ways and what do u mean by Sync methods are preferred ?

Hi @maliming

Error Log :

2021-05-27 11:18:46.476 +05:30 [ERR] ValueFactory attempted to access the Value property of this instance.
System.InvalidOperationException: ValueFactory attempted to access the Value property of this instance.
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.get_PermissionDefinitions()
   at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.GetOrNull(String name)
   at Volo.Abp.Authorization.AbpAuthorizationPolicyProvider.GetPolicyAsync(String policyName)
   at Microsoft.AspNetCore.Authorization.AuthorizationPolicy.CombineAsync(IAuthorizationPolicyProvider policyProvider, IEnumerable`1 authorizeData)
   at Volo.Abp.Authorization.MethodInvocationAuthorizationService.CheckAsync(MethodInvocationAuthorizationContext context)
   at Volo.Abp.Authorization.AuthorizationInterceptor.AuthorizeAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task`1 task)
   at Nito.AsyncEx.AsyncContext.<>c__DisplayClass16_0`1.&lt;Run&gt;b__0(Task`1 t)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
   at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task`1 task)
   at Nito.AsyncEx.AsyncContext.Run[TResult](Func`1 action)
   at Volo.Abp.Threading.AsyncHelper.RunSync[TResult](Func`1 func)
   at SCV.Litmus.Permissions.LitmusPermissionDefinitionProvider.GetRoles() in D:\Litmus\Projects\core-platform\SCV.Litmus\aspnet-core\modules\litmus-core\src\SCV.Litmus.Application.Contracts\Permissions\LitmusPermissionDefinitionProvider.cs:line 64
   at SCV.Litmus.Permissions.LitmusPermissionDefinitionProvider.Define(IPermissionDefinitionContext context) in D:\Litmus\Projects\core-platform\SCV.Litmus\aspnet-core\modules\litmus-core\src\SCV.Litmus.Application.Contracts\Permissions\LitmusPermissionDefinitionProvider.cs:line 57
   at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.CreatePermissionGroupDefinitions()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.CreatePermissionDefinitions()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.get_PermissionDefinitions()
   at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.GetPermissions()
   at Volo.Abp.Authorization.AbpAuthorizationPolicyProvider.GetPoliciesNamesAsync()
   at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationAppService.GetAuthConfigAsync()
   at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationAppService.GetAsync()
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync()
   at lambda_method(Closure , Object )
   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

My Code :

public class LitmusPermissionDefinitionProvider : PermissionDefinitionProvider
    {
        protected IServiceProvider _serviceProvider { get; }
        public LitmusPermissionDefinitionProvider(IServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;
        }

        public override void Define(IPermissionDefinitionContext context)
        {
            var myGroup = context.AddGroup(LitmusPermissions.GroupName);

            var TestPermissionTestPermission = myGroup.AddPermission("TestRoles");
            var roles = GetRoles();
            foreach (var item in roles)
                TestPermissionTestPermission.AddChild(item);
        }

        private string[] GetRoles()
        {
            var result = AsyncHelper.RunSync(() => _serviceProvider.GetRequiredService<IIdentityRoleAppService>().GetAllListAsync());
            return result.Items.Select(x => x.Name).ToArray();
        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<LitmusResource>(name);
        }
    }

I tried your way, still stuck with same error. If I am doing it wrong way, please provide sample code.

Thanks

Showing 41 to 50 of 85 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06