fix: user delete

This commit is contained in:
Pieter Kuyck
2021-03-13 12:34:47 +01:00
parent 51687c382d
commit 801615c981
3 changed files with 12 additions and 2 deletions

View File

@ -271,6 +271,7 @@ namespace Oqtane.Controllers
if (result != null) if (result != null)
{ {
_folders.DeleteUserFolder(id);
_users.DeleteUser(id); _users.DeleteUser(id);
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Deleted {UserId}", 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.Folder.Remove(folder);
_db.SaveChanges(); _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) public string GetFolderPath(int folderId)
{ {
Folder folder = _db.Folder.Find(folderId); Folder folder = _db.Folder.Find(folderId);

View File

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