mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
Add unique user name checking to the account creation.
This commit is contained in:
@@ -16,7 +16,7 @@ trait AccountControllerBase extends ControllerBase {
|
|||||||
case class AccountEditForm(password: Option[String], mailAddress: String, url: Option[String])
|
case class AccountEditForm(password: Option[String], mailAddress: String, url: Option[String])
|
||||||
|
|
||||||
val newForm = mapping(
|
val newForm = mapping(
|
||||||
"userName" -> trim(label("User name" , text(required, maxlength(100)))),
|
"userName" -> trim(label("User name" , text(required, maxlength(100), identifier, unique))),
|
||||||
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))),
|
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))),
|
||||||
"url" -> trim(label("URL" , optional(text(maxlength(200)))))
|
"url" -> trim(label("URL" , optional(text(maxlength(200)))))
|
||||||
@@ -66,4 +66,10 @@ trait AccountControllerBase extends ControllerBase {
|
|||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
} else NotFound
|
} else NotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def unique: Constraint = new Constraint(){
|
||||||
|
def validate(name: String, value: String): Option[String] =
|
||||||
|
getAccountByUserName(value).map { _ => "User already exists." }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="password"><strong>Password</strong>
|
<label for="password"><strong>Password</strong>
|
||||||
@if(account.nonEmpty){
|
@if(account.nonEmpty){
|
||||||
(Input if you want to change password)
|
(Input to change password)
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
<input type="password" name="password" id="password" value=""/>
|
<input type="password" name="password" id="password" value=""/>
|
||||||
|
|||||||
@@ -9,8 +9,12 @@
|
|||||||
<span id="error-userName" class="error"></span>
|
<span id="error-userName" class="error"></span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="password"><strong>Password</strong></label>
|
<label for="password"><strong>Password</strong>
|
||||||
<input type="password" name="password" id="password" value="@account.map(_.password)"/>
|
@if(account.isDefined){
|
||||||
|
(Input to change password)
|
||||||
|
}
|
||||||
|
</label>
|
||||||
|
<input type="password" name="password" id="password" value=""/>
|
||||||
<span id="error-password" class="error"></span>
|
<span id="error-password" class="error"></span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user