mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
Rename StringUtil#encrypt() to sha1().
This commit is contained in:
@@ -70,7 +70,7 @@ trait AccountControllerBase extends AccountManagementControllerBase with FlashMa
|
|||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map { account =>
|
getAccountByUserName(userName).map { account =>
|
||||||
updateAccount(account.copy(
|
updateAccount(account.copy(
|
||||||
password = form.password.map(encrypt).getOrElse(account.password),
|
password = form.password.map(sha1).getOrElse(account.password),
|
||||||
mailAddress = form.mailAddress,
|
mailAddress = form.mailAddress,
|
||||||
url = form.url))
|
url = form.url))
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ trait AccountControllerBase extends AccountManagementControllerBase with FlashMa
|
|||||||
|
|
||||||
post("/register", newForm){ form =>
|
post("/register", newForm){ form =>
|
||||||
if(loadSystemSettings().allowAccountRegistration){
|
if(loadSystemSettings().allowAccountRegistration){
|
||||||
createAccount(form.userName, encrypt(form.password), form.mailAddress, false, form.url)
|
createAccount(form.userName, sha1(form.password), form.mailAddress, false, form.url)
|
||||||
updateImage(form.userName, form.fileId, false)
|
updateImage(form.userName, form.fileId, false)
|
||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
} else NotFound
|
} else NotFound
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ trait SignInControllerBase extends ControllerBase { self: SystemSettingsService
|
|||||||
|
|
||||||
post("/signin", form){ form =>
|
post("/signin", form){ form =>
|
||||||
val account = getAccountByUserName(form.userName)
|
val account = getAccountByUserName(form.userName)
|
||||||
if(account.isEmpty || account.get.password != encrypt(form.password)){
|
if(account.isEmpty || account.get.password != sha1(form.password)){
|
||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
} else {
|
} else {
|
||||||
session.setAttribute("LOGIN_ACCOUNT", account.get)
|
session.setAttribute("LOGIN_ACCOUNT", account.get)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ trait UserManagementControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/users/_new", newForm)(adminOnly { form =>
|
post("/admin/users/_new", newForm)(adminOnly { form =>
|
||||||
createAccount(form.userName, encrypt(form.password), form.mailAddress, form.isAdmin, form.url)
|
createAccount(form.userName, sha1(form.password), form.mailAddress, form.isAdmin, form.url)
|
||||||
updateImage(form.userName, form.fileId, false)
|
updateImage(form.userName, form.fileId, false)
|
||||||
redirect("/admin/users")
|
redirect("/admin/users")
|
||||||
})
|
})
|
||||||
@@ -61,7 +61,7 @@ trait UserManagementControllerBase extends AccountManagementControllerBase {
|
|||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map { account =>
|
getAccountByUserName(userName).map { account =>
|
||||||
updateAccount(getAccountByUserName(userName).get.copy(
|
updateAccount(getAccountByUserName(userName).get.copy(
|
||||||
password = form.password.map(encrypt).getOrElse(account.password),
|
password = form.password.map(sha1).getOrElse(account.password),
|
||||||
mailAddress = form.mailAddress,
|
mailAddress = form.mailAddress,
|
||||||
isAdmin = form.isAdmin,
|
isAdmin = form.isAdmin,
|
||||||
url = form.url))
|
url = form.url))
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
|
|||||||
|
|
||||||
private def isWritableUser(username: String, password: String, repository: RepositoryService.RepositoryInfo): Boolean = {
|
private def isWritableUser(username: String, password: String, repository: RepositoryService.RepositoryInfo): Boolean = {
|
||||||
getAccountByUserName(username).map { account =>
|
getAccountByUserName(username).map { account =>
|
||||||
account.password == encrypt(password) && hasWritePermission(repository.owner, repository.name, Some(account))
|
account.password == sha1(password) && hasWritePermission(repository.owner, repository.name, Some(account))
|
||||||
} getOrElse false
|
} getOrElse false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package util
|
|||||||
|
|
||||||
object StringUtil {
|
object StringUtil {
|
||||||
|
|
||||||
def encrypt(value: String): String = {
|
def sha1(value: String): String = {
|
||||||
val md = java.security.MessageDigest.getInstance("SHA-1")
|
val md = java.security.MessageDigest.getInstance("SHA-1")
|
||||||
md.update(value.getBytes)
|
md.update(value.getBytes)
|
||||||
md.digest.map(b => "%02x".format(b)).mkString
|
md.digest.map(b => "%02x".format(b)).mkString
|
||||||
|
|||||||
Reference in New Issue
Block a user