
* Moved Collapse Series with relationships into a user preference rather than library setting. * Fixed bookmarks not converting to webp after initial save * Fixed a bug where when merging we'd print out a duplicate series error when we shouldn't have * Fixed a bug where clicking on a genre or tag from server stats wouldn't load all-series page in a filtered state. * Implemented the ability to have Login role and thus disable accounts. * Ensure first time flow gets the Login role * Refactored user management screen so that pending users can be edited or deleted before the end user accepts the invite. A side effect is old legacy users that were here before email was required can now be deleted. * Show a progress bar under the main series image on larger viewports to show whole series progress. * Removed code no longer needed * Cleanup tags, people, collections without connections after editing series metadata. * Moved the Entity Builders to the main project
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System.Threading.Tasks;
|
|
using API.Constants;
|
|
using API.Entities;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace API.Data;
|
|
|
|
/// <summary>
|
|
/// Added in v0.7.1.18
|
|
/// </summary>
|
|
public static class MigrateLoginRoles
|
|
{
|
|
/// <summary>
|
|
/// Will not run if any users have the <see cref="PolicyConstants.LoginRole"/> role already
|
|
/// </summary>
|
|
/// <param name="unitOfWork"></param>
|
|
/// <param name="userManager"></param>
|
|
/// <param name="logger"></param>
|
|
public static async Task Migrate(IUnitOfWork unitOfWork, UserManager<AppUser> userManager, ILogger<Program> logger)
|
|
{
|
|
var usersWithRole = await userManager.GetUsersInRoleAsync(PolicyConstants.LoginRole);
|
|
if (usersWithRole.Count != 0) return;
|
|
|
|
logger.LogCritical("Running MigrateLoginRoles migration");
|
|
|
|
var allUsers = await unitOfWork.UserRepository.GetAllUsersAsync();
|
|
foreach (var user in allUsers)
|
|
{
|
|
await userManager.RemoveFromRoleAsync(user, PolicyConstants.LoginRole);
|
|
await userManager.AddToRoleAsync(user, PolicyConstants.LoginRole);
|
|
}
|
|
|
|
logger.LogInformation("MigrateLoginRoles migration complete");
|
|
}
|
|
}
|