All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gitbucket.core.service.SshKeyService.scala Maven / Gradle / Ivy

The newest version!
package gitbucket.core.service

import gitbucket.core.model.SshKey
import gitbucket.core.model.Profile._
import gitbucket.core.model.Profile.profile.blockingApi._

trait SshKeyService {

  def addPublicKey(userName: String, title: String, publicKey: String)(implicit s: Session): Unit =
    SshKeys.insert(SshKey(userName = userName, title = title, publicKey = publicKey))

  def getPublicKeys(userName: String)(implicit s: Session): List[SshKey] =
    SshKeys.filter(_.userName === userName.bind).sortBy(_.sshKeyId).list

  def getAllKeys()(implicit s: Session): List[SshKey] =
    SshKeys.filter(_.publicKey.trim =!= "").list

  def deletePublicKey(userName: String, sshKeyId: Int)(implicit s: Session): Unit =
    SshKeys.filter(_.byPrimaryKey(userName, sshKeyId)).delete

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy