mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
(refs #115)Fix account registration page and add public key deletion
This commit is contained in:
@@ -184,12 +184,19 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
redirect(s"/${userName}/_ssh")
|
redirect(s"/${userName}/_ssh")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
get("/:userName/_ssh/delete/:id")(oneselfOnly {
|
||||||
|
val userName = params("userName")
|
||||||
|
val sshKeyId = params("id").toInt
|
||||||
|
deletePublicKey(userName, sshKeyId)
|
||||||
|
redirect(s"/${userName}/_ssh")
|
||||||
|
})
|
||||||
|
|
||||||
get("/register"){
|
get("/register"){
|
||||||
if(loadSystemSettings().allowAccountRegistration){
|
if(loadSystemSettings().allowAccountRegistration){
|
||||||
if(context.loginAccount.isDefined){
|
if(context.loginAccount.isDefined){
|
||||||
redirect("/")
|
redirect("/")
|
||||||
} else {
|
} else {
|
||||||
account.html.edit(None, None)
|
account.html.register()
|
||||||
}
|
}
|
||||||
} else NotFound
|
} else NotFound
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,8 @@ trait SshKeyService {
|
|||||||
def getPublicKeys(userName: String): List[SshKey] =
|
def getPublicKeys(userName: String): List[SshKey] =
|
||||||
Query(SshKeys).filter(_.userName is userName.bind).sortBy(_.sshKeyId).list
|
Query(SshKeys).filter(_.userName is userName.bind).sortBy(_.sshKeyId).list
|
||||||
|
|
||||||
|
def deletePublicKey(userName: String, sshKeyId: Int): Unit =
|
||||||
|
SshKeys filter (_.byPrimaryKey(userName, sshKeyId)) delete
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
48
src/main/twirl/account/register.scala.html
Normal file
48
src/main/twirl/account/register.scala.html
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
@()(implicit context: app.Context)
|
||||||
|
@import context._
|
||||||
|
@import view.helpers._
|
||||||
|
@html.main("Create your account"){
|
||||||
|
<h3>Create your account</h3>
|
||||||
|
<form action="@path/register" method="POST" validate="true">
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span6">
|
||||||
|
<fieldset>
|
||||||
|
<label for="userName" class="strong">Username:</label>
|
||||||
|
<input type="text" name="userName" id="userName" value=""/>
|
||||||
|
<span id="error-userName" class="error"></span>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<label for="password" class="strong">
|
||||||
|
Password:
|
||||||
|
</label>
|
||||||
|
<input type="password" name="password" id="password" value=""/>
|
||||||
|
<span id="error-password" class="error"></span>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<label for="fullName" class="strong">Full Name:</label>
|
||||||
|
<input type="text" name="fullName" id="fullName" value=""/>
|
||||||
|
<span id="error-fullName" class="error"></span>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<label for="mailAddress" class="strong">Mail Address:</label>
|
||||||
|
<input type="text" name="mailAddress" id="mailAddress" value=""/>
|
||||||
|
<span id="error-mailAddress" class="error"></span>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<label for="url" class="strong">URL (optional):</label>
|
||||||
|
<input type="text" name="url" id="url" style="width: 400px;" value=""/>
|
||||||
|
<span id="error-url" class="error"></span>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
<div class="span6">
|
||||||
|
<fieldset>
|
||||||
|
<label for="avatar" class="strong">Image (optional):</label>
|
||||||
|
@helper.html.uploadavatar(None)
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<fieldset class="margin">
|
||||||
|
<input type="submit" class="btn btn-success" value="Create account"/>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header">SSH Keys</div>
|
<div class="box-header">SSH Keys</div>
|
||||||
<div class="box-content">
|
<div class="box-content">
|
||||||
@sshKeys.map { sshKey =>
|
@sshKeys.map { key =>
|
||||||
<strong>@sshKey.title</strong>
|
<strong>@key.title</strong>
|
||||||
<a href="#" class="btn btn-mini btn-danger pull-right">Delete</a>
|
<a href="@path/@account.userName/_ssh/delete/@key.sshKeyId" class="btn btn-mini btn-danger pull-right">Delete</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user