Activities of "lalitChougule"

HI @liangshiwei,

Sorry but replicating the architecture will be time taking and we need to resolve it in a give timeline, Can we just connect and may be you can have a look of the project structure and code ? It will be really helpfull

Thanks

  • 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,

I am working with Authorization, Roles and Permission on Microservice architecture.

I have one role i.e. Anchor in which I have created few policies as below

  1. Supplier
  2. Supplier.Create
  3. Supplier.Edit
  4. Supplier.Delete
  5. Supplier.View

Case 1 : On my Role permission level i.e. Anchor I have only check box selected for Supplier Now I have one User i.e. Anchor.Admin, On user permission Ievel I have options like Supplier which is already selected, I assume this is because role(i.e. Anchor) have this option selected. Now I select one more policy for this user like say Supplier.View Expectation : Anchor.Admin should see supplier tab/menu and once the user click on view button user should be able to see the data on the popup screen because this user have Supplier.View policy selected in User permission level screen.

Case 2 : On my Role permission level i.e. Anchor(same role as case 1) I have only check box selected for Supplier Now I have one User i.e. AnchorForCheck.Admin, On user permission Ievel I have options like Supplier which is already selected, I assume this is because role(i.e. Anchor) have this option selected. Expectation : Anchor.Admin should see supplier tab/menu but once the user click on view button user should not be able to see the data on the popup screen because this user have only Supplier policy selected and no other is selected in User permission level screen.

AppService Level : I have this annotation in place above my method [Authorize(ProfileManagementPermissions.Supplier.View)]

My Issue : In both case 1 and case 2 because of the authorize annotation placed on my method I am getting this error on UI :

An error has occurred!
Authorization failed! Given policy has not granted

But on my browsers if I check in network I am getting proper data for grantedPolicies :

Case 1:

  1. ProfileManagement.Supplier: true
  2. ProfileManagement.Supplier.View: true

Case 2:

  1. ProfileManagement.Supplier: true

One more thing I need to highlight here is on my ApplicationService level I dont get info like CurrentUser.Id and CurrentTenant.Id Is this something to do with my architecture or am I missing any refrences or something. I need to make it work for my Role + User level combination of permissions, as case 1 and 2 discussed above. In case you need more details for understanding, Please do ask.

Thanks

  • 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, I want to remove/hide the red color box content like Audit Logging permissions and other policies from the UI. This is for my Tenant admin UI and I don't want to give irrelevant/unnecessary options for my user to play around with. Where do I need to do respective changes. I was not able to find it in doc's.

Thanks

Hi @alpher,

I tried implementing your solution but now I am facing the below issue : SQLite Error 1: 'no such table: AbpUsers'.

Hi,

If you go through all the above mentioned issue, I was finally able to create users in Project B. But now in Project B all unit test cases are failing and all have the same error as below :

Message: 
    Volo.Abp.AbpInitializationException : An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.AspNetCore.Mvc.AbpAspNetCoreMvcModule, Volo.Abp.AspNetCore.Mvc, Version=3.0.4.0, Culture=neutral, PublicKeyToken=null: Could not find singleton service: Microsoft.AspNetCore.Hosting.IWebHostEnvironment, Microsoft.AspNetCore.Hosting.Abstractions, Version=3.1.12.0, Culture=neutral, PublicKeyToken=adb9793829ddae60. See the inner exception for details.
    ---- System.InvalidOperationException : Could not find singleton service: Microsoft.AspNetCore.Hosting.IWebHostEnvironment, Microsoft.AspNetCore.Hosting.Abstractions, Version=3.1.12.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
  Stack Trace: 
    ModuleManager.InitializeModules(ApplicationInitializationContext context)
    AbpApplicationBase.InitializeModules()
    AbpApplicationWithExternalServiceProvider.Initialize(IServiceProvider serviceProvider)
    AbpIntegratedTest`1.ctor()
    ProfileManagementTestBase`1.ctor()
    ProfileManagementApplicationTestBase.ctor()
    XYZAppServiceTests.ctor() line 12
    ----- Inner Stack Trace -----
    ServiceCollectionCommonExtensions.GetSingletonInstance[T](IServiceCollection services)
    AbpAspNetCoreServiceCollectionExtensions.GetHostingEnvironment(IServiceCollection services)
    <>c__DisplayClass1_0.<ConfigureServices>b__2(AbpAspNetCoreMvcOptions options)
    PostConfigureOptions`1.PostConfigure(String name, TOptions options)
    OptionsFactory`1.Create(String name)
    <>c__DisplayClass5_0.<Get>b__0()
    Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
    Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
    Lazy`1.CreateValue()
    Lazy`1.get_Value()
    OptionsCache`1.GetOrAdd(String name, Func`1 createOptions)
    OptionsManager`1.Get(String name)
    OptionsManager`1.get_Value()
    AbpAspNetCoreMvcModule.AddApplicationParts(ApplicationInitializationContext context)
    AbpAspNetCoreMvcModule.OnApplicationInitialization(ApplicationInitializationContext context)
    OnApplicationInitializationModuleLifecycleContributor.Initialize(ApplicationInitializationContext context, IAbpModule module)
    ModuleManager.InitializeModules(ApplicationInitializationContext context)

Sorry to reopen the ticket, but to understand the issue I thought It would be better to mention it here itself.

@gterdem

Yup only Module Dependencies part was missing, once I added those dependencies it worked. Thanks alot !!! Appreciate your quick response.

Hi @gterdem ,

Sorry my bad, copy paste issue.

These are the packages

  1. <PackageReference Include="Volo.Abp.Identity.Application" Version="3.0.4" />
  2. <PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="3.0.4" />
  3. <PackageReference Include="Volo.Abp.Identity.HttpApi" Version="3.0.4" />

Still facing same issues

  • 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

Controller.cs

using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SCV.Litmus.LitmusUsers;
using Volo.Abp;

namespace SCV.Litmus.Controllers.LitmusUsers
{
    [RemoteService]
    [Route("api/ApplicationManagement/litmusUser")]
    public class LitmusUserController : LitmusController, ILitmusUserAppService
    {
        private readonly ILitmusUserAppService _litmusUserAppService;

        public LitmusUserController(ILitmusUserAppService litmusUserAppService)
        {
            _litmusUserAppService = litmusUserAppService;
        }

        [HttpPost]
        public virtual Task<LitmusUserOutputDto> CreateAsync(LitmusUserCreateDto input)
        {
            return _litmusUserAppService.CreateAsync(input);
        }
    }
}


My swagger is showing 2 end points

Two end point which are as below :

  1. /api/ApplicationManagement/litmusUser/createUser -- My custom route
  2. /api/app/litmusUser -- Auto generated

I just want my controller to create 1 route which is 1st /api/ApplicationManagement/litmusUser/createUser

Hi

I installed these packages from nuget manager as below

  • <PackageReference Include="Identity.EntityFrameworkCore" Version="1.2.7" />
  • <PackageReference Include="Volo.Abp.Auditing" Version="3.0.4" />
  • <PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="3.0.4" />

My AppService.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Localization;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity;

public class SupplierRegistrationAppService : ProfileManagementAppService, ISupplierRegistrationAppService
{
	private readonly IdentityUserManager _identityUserManager;
    private readonly IIdentityRoleRepository _identityRoleRepository;
	
	public SupplierRegistrationAppService(
		IdentityUserManager identityUserManager,
		IIdentityRoleRepository identityRoleRepository
		)
	{
		_identityUserManager = identityUserManager;
		_identityRoleRepository = identityRoleRepository;
	}
		
	public async Task<LitmusUserOutputDto> CreateUserAsync(LitmusUserCreateDto input)
	{
		var output = new LitmusUserOutputDto();
		if (input.TenantId.HasValue)
		{
			using (CurrentTenant.Change(input.TenantId))
			{
				//User
				var user = new Volo.Abp.Identity.IdentityUser(GuidGenerator.Create(), input.UserName, input.EmailAddress, CurrentTenant.Id);
				(await _identityUserManager.CreateAsync(user, input.Password)).CheckErrors();
				await _identityUserManager.SetEmailAsync(user, input.EmailAddress);
				user.Name = input.FirstName;
				user.Surname = input.LastName;

				//Role
				IEnumerable<string> rolesIEnum = await GetRoleNames(input.RoleName);
				await _identityUserManager.SetRolesAsync(user, rolesIEnum);

				//Output
				output.EmailId = user.Email;
				output.Password = input.Password;
				output.UserId = user.Id;

			}
		}
		else
			throw new Exception("Tenant Id cannot be empty in CreateAsync()");

		return output;
	}

	private async Task<IEnumerable<string>> GetRoleNames(string RoleName)
	{
		var roles = await _identityRoleRepository.GetListAsync();
		var role = roles.Where(x => x.Name.Equals(RoleName)).FirstOrDefault();
		var rolesList = new List<string>() { role.Name };
		IEnumerable<string> rolesIEnum = rolesList;
		return rolesIEnum;
	}
}

My Controller.cs

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace SCV.Litmus.ProfileManagement.SupplierRegistrations
{
    [RemoteService]
    [Route("profile/api/ProfileManagement")]
    public class SupplierRegistrationController : ProfileManagementController, ISupplierRegistrationAppService
    {
        private readonly ISupplierRegistrationAppService _SupplierRegistrationAppService;

        public SupplierRegistrationController(ISupplierRegistrationAppService SupplierRegistrationAppService)
        {
            _SupplierRegistrationAppService = SupplierRegistrationAppService;
        }

        [HttpPost]
        [Route("createUser")]
        public virtual Task<LitmusUserOutputDto> CreateUserAsync(LitmusUserCreateDto input)
        {
            return _SupplierRegistrationAppService.CreateUserAsync(input);
        }
    }
}

I was able to get references, but now executing this method I am getting the below error :

2021-03-22 16:31:36.999 +05:30 [ERR] An exception was thrown while activating SCV.Litmus.ProfileManagement.SupplierRegistrations.SupplierRegistrationController -> SCV.Litmus.ProfileManagement.SupplierRegistrations.SupplierRegistrationAppService.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating SCV.Litmus.ProfileManagement.SupplierRegistrations.SupplierRegistrationController -> SCV.Litmus.ProfileManagement.SupplierRegistrations.SupplierRegistrationAppService.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'SCV.Litmus.ProfileManagement.SupplierRegistrations.SupplierRegistrationAppService' can be invoked with the available services and parameters:
Cannot resolve parameter 'Volo.Abp.Identity.IdentityUserManager identityUserManager' of constructor 'Void .ctor(SCV.Litmus.ProfileManagement.SupplierRegistrations.ISupplierRegistrationRepository, SCV.Litmus.ProfileManagement.Suppliers.ISupplierRepository, SCV.Litmus.ProfileManagement.Suppliers.ISupplierCodeRepository, SCV.Litmus.ProfileManagement.BusinessEntities.IBusinessEntityRepository, SCV.Litmus.ProfileManagement.SupplierUserProfiles.ISupplierUserProfileRepository, SCV.Litmus.ProfileManagement.SharedServices.ISharedAppService, Volo.Abp.Identity.IdentityUserManager, Volo.Abp.Identity.IIdentityRoleRepository)'.
   at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(ConstructorInfo[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.CreateInstance(IEnumerable`1 parameters)
   --- End of inner exception stack trace ---
   at Autofac.Core.Resolving.InstanceLookup.CreateInstance(IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
   at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(ResolveRequest request)
   at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request)
   at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType)
   at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.&lt;&gt;c__DisplayClass5_0.&lt;CreateControllerFactory&gt;g__CreateController|0(ControllerContext controllerContext)
   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.&lt;InvokeNextExceptionFilterAsync&gt;g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2021-03-22 16:31:37.043 +05:30 [ERR] ---------- Exception Data ----------
2021-03-22 16:31:37.044 +05:30 [ERR] ActivatorChain = SCV.Litmus.ProfileManagement.SupplierRegistrations.SupplierRegistrationController -> SCV.Litmus.ProfileManagement.SupplierRegistrations.SupplierRegistrationAppService

Hi @bunyamin,

I tried this observe: 'response' but I was getting header as null, Is there any other way ? Cause as I said before If I try abp.io rest service then I am getting json parsing error and if I try by angular http approach I am able download the file but I am not able to get access of Content-Disposition where I am getting name of the file. Please check my code above once for your reference.

Showing 81 to 90 of 124 entries
Made with ❤️ on ABP v9.2.0-preview. Updated on January 14, 2025, 14:54