Skip to content

Commit

Permalink
AbpProfileService.IsActiveAsync doesn't check if the user is Active. F…
Browse files Browse the repository at this point in the history
…ixed #3762
  • Loading branch information
alirizaadiyahsi committed Sep 6, 2018
1 parent f4a9488 commit bd316e2
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -3,15 +3,17 @@
using Abp.Domain.Uow;
using Abp.Runtime.Security;
using IdentityServer4.AspNetIdentity;
using IdentityServer4.Extensions;
using IdentityServer4.Models;
using Microsoft.AspNetCore.Identity;

namespace Abp.IdentityServer4
{
public class AbpProfileService<TUser> : ProfileService<TUser>
public class AbpProfileService<TUser> : ProfileService<TUser>
where TUser : AbpUser<TUser>
{
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly UserManager<TUser> _userManager;

public AbpProfileService(
UserManager<TUser> userManager,
Expand All @@ -20,6 +22,7 @@ IUnitOfWorkManager unitOfWorkManager
) : base(userManager, claimsFactory)
{
_unitOfWorkManager = unitOfWorkManager;
_userManager = userManager;
}

[UnitOfWork]
Expand All @@ -38,7 +41,10 @@ public override async Task IsActiveAsync(IsActiveContext context)
var tenantId = context.Subject.Identity.GetTenantId();
using (_unitOfWorkManager.Current.SetTenantId(tenantId))
{
await base.IsActiveAsync(context);
var sub = context.Subject.GetSubjectId();
var user = await _userManager.FindByIdAsync(sub);

context.IsActive = user != null && user.IsActive;
}
}
}
Expand Down

0 comments on commit bd316e2

Please sign in to comment.