mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
(refs #114)Add functionality to remove account by themselves.
This commit is contained in:
@@ -6,6 +6,7 @@ import util.StringUtil._
|
|||||||
import util.Directory._
|
import util.Directory._
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import jp.sf.amateras.scalatra.forms._
|
||||||
import org.scalatra.FlashMapSupport
|
import org.scalatra.FlashMapSupport
|
||||||
|
import org.apache.commons.io.FileUtils
|
||||||
|
|
||||||
class AccountController extends AccountControllerBase
|
class AccountController extends AccountControllerBase
|
||||||
with SystemSettingsService with AccountService with RepositoryService with ActivityService
|
with SystemSettingsService with AccountService with RepositoryService with ActivityService
|
||||||
@@ -97,6 +98,27 @@ trait AccountControllerBase extends AccountManagementControllerBase with FlashMa
|
|||||||
} getOrElse NotFound
|
} getOrElse NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
|
get("/:userName/_delete")(oneselfOnly {
|
||||||
|
val userName = params("userName")
|
||||||
|
|
||||||
|
getAccountByUserName(userName, true).foreach { account =>
|
||||||
|
// Remove repositories
|
||||||
|
getRepositoryNamesOfUser(userName).foreach { repositoryName =>
|
||||||
|
deleteRepository(userName, repositoryName)
|
||||||
|
FileUtils.deleteDirectory(getRepositoryDir(userName, repositoryName))
|
||||||
|
FileUtils.deleteDirectory(getWikiRepositoryDir(userName, repositoryName))
|
||||||
|
FileUtils.deleteDirectory(getTemporaryDir(userName, repositoryName))
|
||||||
|
}
|
||||||
|
// Remove from GROUP_MEMBER, COLLABORATOR and REPOSITORY
|
||||||
|
removeUserRelatedData(userName)
|
||||||
|
|
||||||
|
updateAccount(account.copy(isRemoved = true))
|
||||||
|
}
|
||||||
|
|
||||||
|
session.invalidate
|
||||||
|
redirect("/")
|
||||||
|
})
|
||||||
|
|
||||||
get("/register"){
|
get("/register"){
|
||||||
if(loadSystemSettings().allowAccountRegistration){
|
if(loadSystemSettings().allowAccountRegistration){
|
||||||
if(context.loginAccount.isDefined){
|
if(context.loginAccount.isDefined){
|
||||||
|
|||||||
@@ -56,6 +56,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<fieldset class="margin">
|
<fieldset class="margin">
|
||||||
@if(account.isDefined){
|
@if(account.isDefined){
|
||||||
|
<div class="pull-right">
|
||||||
|
<a href="@path/@account.get.userName/_delete" class="btn btn-danger" id="delete">Delete account</a>
|
||||||
|
</div>
|
||||||
<input type="submit" class="btn btn-success" value="Save"/>
|
<input type="submit" class="btn btn-success" value="Save"/>
|
||||||
<a href="@url(account.get.userName)" class="btn">Cancel</a>
|
<a href="@url(account.get.userName)" class="btn">Cancel</a>
|
||||||
} else {
|
} else {
|
||||||
@@ -64,3 +67,10 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
$('#delete').click(function(){
|
||||||
|
return confirm('Once you delete your account, there is no going back.\nAre you sure?');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user