mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-01 11:06:06 +01:00
move filtering into the database
This commit is contained in:
@@ -13,7 +13,7 @@ trait SshKeyService {
|
||||
SshKeys.filter(_.userName === userName.bind).sortBy(_.sshKeyId).list
|
||||
|
||||
def getAllKeys()(implicit s: Session): List[SshKey] =
|
||||
SshKeys.list
|
||||
SshKeys.filter(_.publicKey.trim =!= "").list
|
||||
|
||||
def deletePublicKey(userName: String, sshKeyId: Int)(implicit s: Session): Unit =
|
||||
SshKeys filter (_.byPrimaryKey(userName, sshKeyId)) delete
|
||||
|
||||
@@ -51,10 +51,7 @@ class PublicKeyAuthenticator(genericUser:String) extends PublickeyAuthenticator
|
||||
Database()
|
||||
.withSession { implicit dbSession => getAllKeys() }
|
||||
.filter { sshKey =>
|
||||
Option(sshKey.publicKey)
|
||||
.filter(_.trim.nonEmpty)
|
||||
.flatMap(SshUtil.str2PublicKey)
|
||||
.exists(_ == key)
|
||||
SshUtil.str2PublicKey(sshKey.publicKey).exists(_ == key)
|
||||
}
|
||||
.map(_.userName)
|
||||
.distinct
|
||||
|
||||
Reference in New Issue
Block a user