Add removeUser method for move responsibility of calling hooks

This commit is contained in:
KOUNOIKE
2018-10-07 13:31:43 +09:00
parent 80b50f6fa9
commit efff209ebd
2 changed files with 10 additions and 7 deletions

View File

@@ -360,13 +360,6 @@ trait AccountControllerBase extends AccountManagementControllerBase {
// FileUtils.deleteDirectory(getWikiRepositoryDir(userName, repositoryName))
// FileUtils.deleteDirectory(getTemporaryDir(userName, repositoryName))
// }
// Remove from GROUP_MEMBER and COLLABORATOR
removeUserRelatedData(userName)
updateAccount(account.copy(isRemoved = true))
// call hooks
PluginRegistry().getAccountHooks.foreach(_.deleted(userName))
session.invalidate
redirect("/")
}

View File

@@ -7,6 +7,7 @@ import gitbucket.core.model.Profile.profile.blockingApi._
import gitbucket.core.model.Profile.dateColumnType
import gitbucket.core.util.{LDAPUtil, StringUtil}
import StringUtil._
import gitbucket.core.plugin.PluginRegistry
import gitbucket.core.service.SystemSettingsService.SystemSettings
trait AccountService {
@@ -278,6 +279,15 @@ trait AccountService {
Collaborators.filter(_.collaboratorName === userName.bind).delete
}
def removeUser(account: Account)(implicit s: Session): Unit = {
// Remove from GROUP_MEMBER and COLLABORATOR
removeUserRelatedData(account.userName)
updateAccount(account.copy(isRemoved = true))
// call hooks
PluginRegistry().getAccountHooks.foreach(_.deleted(account.userName))
}
def getGroupNames(userName: String)(implicit s: Session): List[String] = {
List(userName) ++
Collaborators.filter(_.collaboratorName === userName.bind).sortBy(_.userName).map(_.userName).list.distinct