Activities of "liangshiwei"

Hi,

Can you share detail logs? (include identityServer and HttpApi.Host)

Hi,

You can use RabbitMQ only for background jobs, remove all AbpEventBusRabbitMqModule from your solution.then you can safely remove Rabbitmq's EventBus configuration.

Hi,

We will check it.

Hi,

Please try:

public static class RefreshRolesMiddlewareExtension
{
    public static IApplicationBuilder UseRefreshRolesMiddleware(this IApplicationBuilder app)
    {
        return app.Use(async (ctx, next) =>
        {
            var currentUser = ctx.RequestServices.GetRequiredService<ICurrentUser>();

            if (!currentUser.IsAuthenticated)
            {
                await next();
                return;
            }

            var userManager = ctx.RequestServices.GetRequiredService<IdentityUserManager>();

            var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService<ICurrentPrincipalAccessor>();
            var user = await userManager.GetByIdAsync(currentUser.GetId());
            var roles= await userManager.GetRolesAsync(user);

            currentPrincipalAccessor.Principal.Identities.First().AddClaims(roles.Select(x=> new Claim(AbpClaimTypes.Role, x)));

            await next();

        });
    }
}

Hi,

It is already included in the headers.

Can you share the HTTP response detail (include header and body)?

Try

public static class RefreshRolesMiddlewareExtension
{
    public static IApplicationBuilder UseRefreshRolesMiddleware(this IApplicationBuilder app)
    {
        return app.Use(async (ctx, next) =>
        {
            var currentUser = ctx.RequestServices.GetRequiredService<ICurrentUser>();

            if (!currentUser.IsAuthenticated)
            {
                await next();
                return;
            }

            var userManager = ctx.RequestServices.GetRequiredService<IdentityUserManager>();

            var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService<ICurrentPrincipalAccessor>();
            var user = await userManager.GetByIdAsync(currentUser.GetId());
            var roles= await userManager.GetRolesAsync(user);
            var claims = currentPrincipalAccessor.Principal.Claims.ToList();

            claims.RemoveAll(x => x.Type == AbpClaimTypes.Role);
            claims.AddRange(roles.Select(x=> new Claim(AbpClaimTypes.Role, x)));

            using (currentPrincipalAccessor.Change(claims))
            {
                await next();
            }
        });
    }
}

Hi,

I have reproduced the problem, thank you, we will fix it. see https://github.com/abpframework/abp/pull/11006

PS: your ticket refunded.

For now, you can try:

[ExposeServices(
    typeof(ICachedApplicationConfigurationClient),
    typeof(IAsyncInitialize)
)]
public class MyMvcCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency
{
    protected IHttpContextAccessor HttpContextAccessor { get; }
    protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; }
    protected ICurrentUser CurrentUser { get; }
    protected IDistributedCache<ApplicationConfigurationDto> Cache { get; }

    public MyMvcCachedApplicationConfigurationClient(
        IDistributedCache<ApplicationConfigurationDto> cache,
        AbpApplicationConfigurationClientProxy applicationConfigurationAppService,
        ICurrentUser currentUser,
        IHttpContextAccessor httpContextAccessor)
    {
        ApplicationConfigurationAppService = applicationConfigurationAppService;
        CurrentUser = currentUser;
        HttpContextAccessor = httpContextAccessor;
        Cache = cache;
    }

    public async Task InitializeAsync()
    {
        await GetAsync();
    }

    public async Task<ApplicationConfigurationDto> GetAsync()
    {
        var cacheKey = CreateCacheKey();
        var httpContext = HttpContextAccessor?.HttpContext;

        if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration)
        {
            return configuration;
        }


        configuration = await Cache.GetOrAddAsync(
            cacheKey,
            async () => await ApplicationConfigurationAppService.GetAsync(),
            () => new DistributedCacheEntryOptions
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300) //TODO: Should be configurable.
            }
        );

        if (httpContext != null)
        {
            httpContext.Items[cacheKey] = configuration;
        }

        return configuration;
    }

    public ApplicationConfigurationDto Get()
    {
        var cacheKey = CreateCacheKey();
        var httpContext = HttpContextAccessor?.HttpContext;

        if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration)
        {
            return configuration;
        }

        return AsyncHelper.RunSync(GetAsync);
    }

    protected virtual string CreateCacheKey()
    {
        var userKey = CurrentUser.Id?.ToString("N") ?? "Anonymous";
        return $"ApplicationConfiguration_{userKey}_{CultureInfo.CurrentUICulture.Name}";
    }
}

Hi,

Yes, IList<IFormFile> and IList<IRemoteStreamContent> both work.

Is there any benefit for me using IList<IRemoteStreamContent> here?

IRemoteStreamContent work with dynamic/static proxy system.

Hi,

The point is ID property, you need to change the API parameter name

Showing 4711 to 4720 of 6037 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 19, 2024, 12:56