diff --git a/src/main/resources/update/1_7.sql b/src/main/resources/update/1_7.sql new file mode 100644 index 0000000..9005ff9 --- /dev/null +++ b/src/main/resources/update/1_7.sql @@ -0,0 +1,5 @@ +ALTER TABLE ACCOUNT ADD COLUMN FULL_NAME VARCHAR(100); + +UPDATE ACCOUNT SET FULL_NAME = USER_NAME WHERE FULL_NAME IS NULL; + +ALTER TABLE ACCOUNT ALTER COLUMN FULL_NAME SET NOT NULL; diff --git a/src/main/scala/app/AccountController.scala b/src/main/scala/app/AccountController.scala index 48b649b..6691bcc 100644 --- a/src/main/scala/app/AccountController.scala +++ b/src/main/scala/app/AccountController.scala @@ -15,15 +15,16 @@ self: SystemSettingsService with AccountService with RepositoryService with ActivityService with OneselfAuthenticator => - case class AccountNewForm(userName: String, password: String,mailAddress: String, + case class AccountNewForm(userName: String, password: String, fullName: String, mailAddress: String, url: Option[String], fileId: Option[String]) - case class AccountEditForm(password: Option[String], mailAddress: String, + case class AccountEditForm(password: Option[String], fullName: String, mailAddress: String, url: Option[String], fileId: Option[String], clearImage: Boolean) val newForm = mapping( "userName" -> trim(label("User name" , text(required, maxlength(100), identifier, uniqueUserName))), "password" -> trim(label("Password" , text(required, maxlength(20)))), + "fullName" -> trim(label("Full Name" , text(required, maxlength(100)))), "mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))), "url" -> trim(label("URL" , optional(text(maxlength(200))))), "fileId" -> trim(label("File ID" , optional(text()))) @@ -31,6 +32,7 @@ val editForm = mapping( "password" -> trim(label("Password" , optional(text(maxlength(20))))), + "fullName" -> trim(label("Full Name" , text(required, maxlength(100)))), "mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress("userName")))), "url" -> trim(label("URL" , optional(text(maxlength(200))))), "fileId" -> trim(label("File ID" , optional(text()))), @@ -84,6 +86,7 @@ getAccountByUserName(userName).map { account => updateAccount(account.copy( password = form.password.map(sha1).getOrElse(account.password), + fullName = form.fullName, mailAddress = form.mailAddress, url = form.url)) @@ -106,7 +109,7 @@ post("/register", newForm){ form => if(loadSystemSettings().allowAccountRegistration){ - createAccount(form.userName, sha1(form.password), form.mailAddress, false, form.url) + createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.url) updateImage(form.userName, form.fileId, false) redirect("/signin") } else NotFound diff --git a/src/main/scala/app/CreateRepositoryController.scala b/src/main/scala/app/CreateRepositoryController.scala index 560b828..ccef6fd 100644 --- a/src/main/scala/app/CreateRepositoryController.scala +++ b/src/main/scala/app/CreateRepositoryController.scala @@ -94,7 +94,7 @@ val git = Git.open(tmpdir) git.add.addFilepattern("README.md").call git.commit - .setCommitter(new PersonIdent(loginUserName, loginAccount.mailAddress)) + .setCommitter(new PersonIdent(loginAccount.fullName, loginAccount.mailAddress)) .setMessage("Initial commit").call git.push.call diff --git a/src/main/scala/app/PullRequestsController.scala b/src/main/scala/app/PullRequestsController.scala index 8219b9c..c3ac905 100644 --- a/src/main/scala/app/PullRequestsController.scala +++ b/src/main/scala/app/PullRequestsController.scala @@ -138,7 +138,7 @@ + form.message) git.commit - .setCommitter(new PersonIdent(loginAccount.userName, loginAccount.mailAddress)) + .setCommitter(new PersonIdent(loginAccount.fullName, loginAccount.mailAddress)) .call // push diff --git a/src/main/scala/app/UserManagementController.scala b/src/main/scala/app/UserManagementController.scala index 1e1f0f5..e0405ed 100644 --- a/src/main/scala/app/UserManagementController.scala +++ b/src/main/scala/app/UserManagementController.scala @@ -12,10 +12,12 @@ trait UserManagementControllerBase extends AccountManagementControllerBase { self: AccountService with RepositoryService with AdminAuthenticator => - case class NewUserForm(userName: String, password: String, mailAddress: String, isAdmin: Boolean, + case class NewUserForm(userName: String, password: String, fullName: String, + mailAddress: String, isAdmin: Boolean, url: Option[String], fileId: Option[String]) - case class EditUserForm(userName: String, password: Option[String], mailAddress: String, isAdmin: Boolean, + case class EditUserForm(userName: String, password: Option[String], fullName: String, + mailAddress: String, isAdmin: Boolean, url: Option[String], fileId: Option[String], clearImage: Boolean) case class NewGroupForm(groupName: String, url: Option[String], fileId: Option[String], @@ -27,6 +29,7 @@ val newUserForm = mapping( "userName" -> trim(label("Username" , text(required, maxlength(100), identifier, uniqueUserName))), "password" -> trim(label("Password" , text(required, maxlength(20)))), + "fullName" -> trim(label("Full Name" , text(required, maxlength(100)))), "mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))), "isAdmin" -> trim(label("User Type" , boolean())), "url" -> trim(label("URL" , optional(text(maxlength(200))))), @@ -36,6 +39,7 @@ val editUserForm = mapping( "userName" -> trim(label("Username" , text(required, maxlength(100), identifier))), "password" -> trim(label("Password" , optional(text(maxlength(20))))), + "fullName" -> trim(label("Full Name" , text(required, maxlength(100)))), "mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress("userName")))), "isAdmin" -> trim(label("User Type" , boolean())), "url" -> trim(label("URL" , optional(text(maxlength(200))))), @@ -71,7 +75,7 @@ }) post("/admin/users/_newuser", newUserForm)(adminOnly { form => - createAccount(form.userName, sha1(form.password), form.mailAddress, form.isAdmin, form.url) + createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, form.isAdmin, form.url) updateImage(form.userName, form.fileId, false) redirect("/admin/users") }) @@ -86,6 +90,7 @@ getAccountByUserName(userName).map { account => updateAccount(getAccountByUserName(userName).get.copy( password = form.password.map(sha1).getOrElse(account.password), + fullName = form.fullName, mailAddress = form.mailAddress, isAdmin = form.isAdmin, url = form.url)) @@ -137,4 +142,4 @@ getAccountByUserName(params("userName")).isDefined }) -} \ No newline at end of file +} diff --git a/src/main/scala/app/WikiController.scala b/src/main/scala/app/WikiController.scala index 71ed5ea..4d141de 100644 --- a/src/main/scala/app/WikiController.scala +++ b/src/main/scala/app/WikiController.scala @@ -139,7 +139,7 @@ val pageName = StringUtil.urlDecode(params("page")) defining(context.loginAccount.get){ loginAccount => - deleteWikiPage(repository.owner, repository.name, pageName, loginAccount.userName, loginAccount.mailAddress, s"Destroyed ${pageName}") + deleteWikiPage(repository.owner, repository.name, pageName, loginAccount.fullName, loginAccount.mailAddress, s"Destroyed ${pageName}") updateLastActivityDate(repository.owner, repository.name) redirect(s"/${repository.owner}/${repository.name}/wiki") @@ -203,4 +203,4 @@ private def targetWikiPage = getWikiPage(params("owner"), params("repository"), params("pageName")) -} \ No newline at end of file +} diff --git a/src/main/scala/model/Account.scala b/src/main/scala/model/Account.scala index 86ff251..4324d0f 100644 --- a/src/main/scala/model/Account.scala +++ b/src/main/scala/model/Account.scala @@ -4,6 +4,7 @@ object Accounts extends Table[Account]("ACCOUNT") { def userName = column[String]("USER_NAME", O PrimaryKey) + def fullName = column[String]("FULL_NAME") def mailAddress = column[String]("MAIL_ADDRESS") def password = column[String]("PASSWORD") def isAdmin = column[Boolean]("ADMINISTRATOR") @@ -13,11 +14,12 @@ def lastLoginDate = column[java.util.Date]("LAST_LOGIN_DATE") def image = column[String]("IMAGE") def groupAccount = column[Boolean]("GROUP_ACCOUNT") - def * = userName ~ mailAddress ~ password ~ isAdmin ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? ~ image.? ~ groupAccount <> (Account, Account.unapply _) + def * = userName ~ fullName ~ mailAddress ~ password ~ isAdmin ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? ~ image.? ~ groupAccount <> (Account, Account.unapply _) } case class Account( userName: String, + fullName: String, mailAddress: String, password: String, isAdmin: Boolean, diff --git a/src/main/scala/service/AccountService.scala b/src/main/scala/service/AccountService.scala index 39ddf6b..38ea894 100644 --- a/src/main/scala/service/AccountService.scala +++ b/src/main/scala/service/AccountService.scala @@ -37,7 +37,7 @@ // Create or update account by LDAP information getAccountByUserName(userName) match { case Some(x) => updateAccount(x.copy(mailAddress = mailAddress)) - case None => createAccount(userName, "", mailAddress, false, None) + case None => createAccount(userName, "", userName, mailAddress, false, None) } getAccountByUserName(userName) } @@ -53,10 +53,11 @@ def getAllUsers(): List[Account] = Query(Accounts) sortBy(_.userName) list - def createAccount(userName: String, password: String, mailAddress: String, isAdmin: Boolean, url: Option[String]): Unit = + def createAccount(userName: String, password: String, fullName: String, mailAddress: String, isAdmin: Boolean, url: Option[String]): Unit = Accounts insert Account( userName = userName, password = password, + fullName = fullName, mailAddress = mailAddress, isAdmin = isAdmin, url = url, @@ -69,9 +70,10 @@ def updateAccount(account: Account): Unit = Accounts .filter { a => a.userName is account.userName.bind } - .map { a => a.password ~ a.mailAddress ~ a.isAdmin ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.? } + .map { a => a.password ~ a.fullName ~ a.mailAddress ~ a.isAdmin ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.? } .update ( account.password, + account.fullName, account.mailAddress, account.isAdmin, account.url, @@ -89,6 +91,7 @@ Accounts insert Account( userName = groupName, password = "", + fullName = groupName, mailAddress = groupName + "@devnull", isAdmin = false, url = url, diff --git a/src/main/scala/service/WikiService.scala b/src/main/scala/service/WikiService.scala index 8802841..bce71e4 100644 --- a/src/main/scala/service/WikiService.scala +++ b/src/main/scala/service/WikiService.scala @@ -130,7 +130,7 @@ try { git.apply.setPatch(new java.io.ByteArrayInputStream(patch.getBytes("UTF-8"))).call git.add.addFilepattern(".").call - git.commit.setCommitter(committer.userName, committer.mailAddress).setMessage(pageName match { + git.commit.setCommitter(committer.fullName, committer.mailAddress).setMessage(pageName match { case Some(x) => s"Revert ${from} ... ${to} on ${x}" case None => s"Revert ${from} ... ${to}" }).call @@ -175,7 +175,7 @@ // commit and push optionIf(added || deleted){ - defining(git.commit.setCommitter(committer.userName, committer.mailAddress) + defining(git.commit.setCommitter(committer.fullName, committer.mailAddress) .setMessage(if(message.trim.length == 0){ if(deleted){ s"Rename ${currentPageName} to ${newPageName}" @@ -234,4 +234,4 @@ } } -} \ No newline at end of file +} diff --git a/src/main/scala/servlet/AutoUpdateListener.scala b/src/main/scala/servlet/AutoUpdateListener.scala index 8351344..1f78018 100644 --- a/src/main/scala/servlet/AutoUpdateListener.scala +++ b/src/main/scala/servlet/AutoUpdateListener.scala @@ -50,6 +50,7 @@ * The history of versions. A head of this sequence is the current BitBucket version. */ val versions = Seq( + Version(1, 7), Version(1, 6), Version(1, 5), Version(1, 4), @@ -155,4 +156,4 @@ servletContext.getInitParameter("db.user"), servletContext.getInitParameter("db.password")) -} \ No newline at end of file +} diff --git a/src/main/twirl/account/edit.scala.html b/src/main/twirl/account/edit.scala.html index 8a2447f..8d8ca9a 100644 --- a/src/main/twirl/account/edit.scala.html +++ b/src/main/twirl/account/edit.scala.html @@ -32,6 +32,11 @@ }
+ } + } -} \ No newline at end of file +}