User Reports
Using the AdminUI reports feature, you can create your own custom user reports to fit your requirements. These can then be run from the user reports screen.
We have included the following reports by default:
-
Report: All Locked Out Users - shows users that are currently locked out.
-
Report: All Users with Unconfirmed Email - shows users that have not confirmed their email address.
Creating a custom user report
Here is an example of the LockedOutUsersReport, this report is setup to return all users that are currently lockedout in a ASP.NET User store.
public class LockedOutUsersReport(IIdentityUnitOfWorkFactory uowFactory, TimeProvider timeProvider) : UserReport("alllockedoutexample", "Report: All Locked Out Users")
{
public override async Task<PagedResult<UserReportRow>> Execute(int page, int pageSize)
{
var uow = uowFactory.Create();
var pagination = new Pagination(page, pageSize);
IQueryable<IdentityExpressUser> queryableUsers = uow.UserManager.Users.Include(x=>x.Claims).Where(x => x.LockoutEnabled && x.LockoutEnd > timeProvider.GetUtcNow());
int userCount = await queryableUsers.CountAsync();
queryableUsers = pagination.ApplyPagination(queryableUsers);
return new PagedResult<UserReportRow>(pagination)
{
Results = (await queryableUsers.ToListAsync()).Select(x=> new UserReportRow(x.Id, x.UserName, x.FirstName + " " + x.LastName, x.Email)),
TotalCount = userCount
};
}
}
The report then needs to be enabled in AdminUI by adding the following to your AddAdminUI method.
builder.Services.AddAdminUI()
.AddUserReport<LockedOutUsersReport>();