Removed old manual migrations (config change, cover images) that are from many releases ago. (#1054)

This commit is contained in:
Joseph Milazzo 2022-02-10 17:39:48 -08:00 committed by GitHub
parent 1871de1cff
commit f0d7f480ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 28 deletions

View file

@ -14,7 +14,8 @@ namespace API.Data;
public static class MigrateBookmarks
{
/// <summary>
/// This will migrate existing bookmarks to bookmark folder based
/// This will migrate existing bookmarks to bookmark folder based.
/// If the bookmarks folder already exists, this will not run.
/// </summary>
/// <remarks>Bookmark directory is configurable. This will always use the default bookmark directory.</remarks>
/// <param name="directoryService"></param>

View file

@ -5,11 +5,23 @@ using Microsoft.AspNetCore.Identity;
namespace API.Data;
/// <summary>
/// New role introduced in v0.5.1. Adds the role to all users.
/// </summary>
public static class MigrateChangePasswordRoles
{
/// <summary>
/// Will not run if any users have the ChangePassword role already
/// </summary>
/// <param name="unitOfWork"></param>
/// <param name="userManager"></param>
public static async Task Migrate(IUnitOfWork unitOfWork, UserManager<AppUser> userManager)
{
foreach (var user in await unitOfWork.UserRepository.GetAllUsers())
var usersWithRole = await userManager.GetUsersInRoleAsync(PolicyConstants.ChangePasswordRole);
if (usersWithRole.Count != 0) return;
var allUsers = await unitOfWork.UserRepository.GetAllUsers();
foreach (var user in allUsers)
{
await userManager.RemoveFromRoleAsync(user, "ChangePassword");
await userManager.AddToRoleAsync(user, PolicyConstants.ChangePasswordRole);