Merge pull request #1178 from Raceeend/user-delete

fix: user delete
This commit is contained in:
Shaun Walker 2021-03-25 13:49:11 -04:00 committed by GitHub
commit 1271064872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -271,6 +271,7 @@ namespace Oqtane.Controllers
if (result != null)
{
_folders.DeleteUserFolder(id);
_users.DeleteUser(id);
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Deleted {UserId}", id);
}

View File

@ -90,7 +90,15 @@ namespace Oqtane.Repository
_db.Folder.Remove(folder);
_db.SaveChanges();
}
public void DeleteUserFolder(int userId)
{
string userFolderPath = Utilities.PathCombine("Users", userId.ToString(), System.IO.Path.DirectorySeparatorChar.ToString());
List<int> folderIdsToDelete = new List<int>(_db.Folder.Where(a => a.Path == userFolderPath).Select(a => a.FolderId));
foreach (int folderId in folderIdsToDelete)
{
DeleteFolder(folderId);
}
}
public string GetFolderPath(int folderId)
{
Folder folder = _db.Folder.Find(folderId);

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Oqtane.Models;
namespace Oqtane.Repository
@ -12,6 +12,7 @@ namespace Oqtane.Repository
Folder GetFolder(int folderId, bool tracking);
Folder GetFolder(int siteId, string path);
void DeleteFolder(int folderId);
void DeleteUserFolder(int userId);
string GetFolderPath(int folderId);
string GetFolderPath(Folder folder);
}