mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 03:26: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
|
SshKeys.filter(_.userName === userName.bind).sortBy(_.sshKeyId).list
|
||||||
|
|
||||||
def getAllKeys()(implicit s: Session): List[SshKey] =
|
def getAllKeys()(implicit s: Session): List[SshKey] =
|
||||||
SshKeys.list
|
SshKeys.filter(_.publicKey.trim =!= "").list
|
||||||
|
|
||||||
def deletePublicKey(userName: String, sshKeyId: Int)(implicit s: Session): Unit =
|
def deletePublicKey(userName: String, sshKeyId: Int)(implicit s: Session): Unit =
|
||||||
SshKeys filter (_.byPrimaryKey(userName, sshKeyId)) delete
|
SshKeys filter (_.byPrimaryKey(userName, sshKeyId)) delete
|
||||||
|
|||||||
@@ -51,10 +51,7 @@ class PublicKeyAuthenticator(genericUser:String) extends PublickeyAuthenticator
|
|||||||
Database()
|
Database()
|
||||||
.withSession { implicit dbSession => getAllKeys() }
|
.withSession { implicit dbSession => getAllKeys() }
|
||||||
.filter { sshKey =>
|
.filter { sshKey =>
|
||||||
Option(sshKey.publicKey)
|
SshUtil.str2PublicKey(sshKey.publicKey).exists(_ == key)
|
||||||
.filter(_.trim.nonEmpty)
|
|
||||||
.flatMap(SshUtil.str2PublicKey)
|
|
||||||
.exists(_ == key)
|
|
||||||
}
|
}
|
||||||
.map(_.userName)
|
.map(_.userName)
|
||||||
.distinct
|
.distinct
|
||||||
|
|||||||
Reference in New Issue
Block a user