Activities of "liangshiwei"

Hi,

Because the database is tenant isolated, I think you can create the same user in each tenant for users with x role.

Hi,

Will this problem also occur if you use a new project to generate a crud page?

PS: You can upgrade CLI and suite to 4.4.0 rc.2 version and try again:

  dotnet tool uninstall --global Volo.Abp.Cli 
  dotnet tool install --global Volo.Abp.Cli --version 4.4.0-rc.2
  abp suite update --preview

HI,

You mean use CLI to send a Http request to app service, right?

See: https://docs.abp.io/en/abp/latest/Multi-Tenancy#tenant-resolvers

Pass the tenant in the query string:

httpClient.RequestTokenAsync(new TokenRequest()
{
    Address = "https://demo.identityserver.io/connect/token?__tenant=xxx", pass the tenant

    GrantType = "password",

    ClientId = "client",
    ClientSecret = "secret",

    Parameters =
    {
        {"username", "xxx"},
        {"password", "xxx"}
    }
});

HI,

You can create a shared entityframeworkcore project used to share the database

Hi,

Okay, thanks.

Hi,

This is the design of the Aspnet Core Identity, I would like to suggest that don't change it if you don't have to

However, you can change it:

[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IdentityUserManager))]
public class MyUserManager : IdentityUserManager
{
    public MyUserManager(
        IdentityUserStore store,
        IIdentityRoleRepository roleRepository,
        IIdentityUserRepository userRepository,
        IOptions<IdentityOptions> optionsAccessor,
        IPasswordHasher<IdentityUser> passwordHasher,
        IEnumerable<IUserValidator<IdentityUser>> userValidators,
        IEnumerable<IPasswordValidator<IdentityUser>> passwordValidators,
        ILookupNormalizer keyNormalizer,
        IdentityErrorDescriber errors,
        IServiceProvider services,
        ILogger<IdentityUserManager> logger,
        ICancellationTokenProvider cancellationTokenProvider,
        IOrganizationUnitRepository organizationUnitRepository,
        ISettingProvider settingProvider) :
        base(store,
            roleRepository,
            userRepository,
            optionsAccessor,
            passwordHasher,
            userValidators,
            passwordValidators,
            keyNormalizer,
            errors,
            services,
            logger,
            cancellationTokenProvider,
            organizationUnitRepository,
            settingProvider)
    {
    }

    public override async Task<IdentityResult> AccessFailedAsync(IdentityUser user)
    {
        ThrowIfDisposed();
        var store = GetUserLockoutStore();
        if (user == null)
        {
            throw new ArgumentNullException(nameof(user));
        }

        // If this puts the user over the threshold for lockout, lock them out and reset the access failed count
        var count = await store.IncrementAccessFailedCountAsync(user, CancellationToken);
        if (count < Options.Lockout.MaxFailedAccessAttempts)
        {
            return await UpdateUserAsync(user);
        }
        Logger.LogWarning(12, "User is locked out.");
        await store.SetLockoutEndDateAsync(user, DateTime.Now.Add(Options.Lockout.DefaultLockoutTimeSpan),
            CancellationToken);
        await store.ResetAccessFailedCountAsync(user, CancellationToken);
        return await UpdateUserAsync(user);
    }

    public override async Task<bool> IsLockedOutAsync(IdentityUser user)
    {
        ThrowIfDisposed();
        var store = GetUserLockoutStore();
        if (user == null)
        {
            throw new ArgumentNullException(nameof(user));
        }
        if (!await store.GetLockoutEnabledAsync(user, CancellationToken))
        {
            return false;
        }
        var lockoutTime = await store.GetLockoutEndDateAsync(user, CancellationToken);
        return lockoutTime >= DateTime.Now;
    }

    private IUserLockoutStore<IdentityUser> GetUserLockoutStore()
    {
        var cast = Store as IUserLockoutStore<IdentityUser>;
        return cast;
    }
}

See: https://support.abp.io/QA/Questions/1628/AsyncBackgroundJobs#answer-9bd678d0-8939-94ff-3d01-39fdfeea6986

HI,

This is a temporary solution:

public class CancellationTokenOverride
{
    public CancellationToken CancellationToken { get; }

    public CancellationTokenOverride(CancellationToken cancellationToken)
    {
        CancellationToken = cancellationToken;
    }
}


[Dependency(ReplaceServices = true)]
public class MyCancellationTokenProvider : ICancellationTokenProvider, ITransientDependency
{

    public const string CancellationTokenOverrideContextKey = "Volo.Abp.Threading.CancellationToken.Override";

    public CancellationToken Token { get
    {
        if (OverrideValue != null)
        {
            return OverrideValue.CancellationToken;
        }
        return _httpContextAccessor.HttpContext?.RequestAborted ?? CancellationToken.None;
    }}

    private readonly IAmbientScopeProvider<CancellationTokenOverride> _cancellationTokenOverrideScopeProvider;
    private readonly IHttpContextAccessor _httpContextAccessor;
    protected CancellationTokenOverride OverrideValue => _cancellationTokenOverrideScopeProvider.GetValue(CancellationTokenOverrideContextKey);

    public MyCancellationTokenProvider(
        IAmbientScopeProvider<CancellationTokenOverride> cancellationTokenOverrideScopeProvider,
        IHttpContextAccessor httpContextAccessor)
    {
        _cancellationTokenOverrideScopeProvider = cancellationTokenOverrideScopeProvider;
        _httpContextAccessor = httpContextAccessor;
    }

    public IDisposable Use(CancellationToken cancellationToken)
    {
        return _cancellationTokenOverrideScopeProvider.BeginScope(CancellationTokenOverrideContextKey, new CancellationTokenOverride(cancellationToken));
    }
}
protected override async Task OnInitializedAsync()
{
    cts.CancelAfter(2000);//To test CancellationToken
    
    using (((MyCancellationTokenProvider) _cancellationTokenProvider).Use(cts.Token))
    {
       var pageResult = await CallsAppService.GetListAsync(new GetCallsInput { });
       Calls = pageResult.Items;
    }
}

Hi,

As I said, currently ABP does not support custom cancellationToken. because the request proxy interceptor always uses the ICancellationTokenProvider.

This PR will solve the issue, but 5.0.0 version, for now, you can implement it locally.

HI,

I can't reproduce the problem, Can you share some screenshots? thanks.

Showing 5451 to 5460 of 6466 entries
Made with ❤️ on ABP v9.2.0-preview. Updated on January 15, 2025, 12:18