diff options
Diffstat (limited to 'models/ssh_key.go')
-rw-r--r-- | models/ssh_key.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go index 0f8e5225bb..27c5bf0808 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -451,11 +451,9 @@ func GetPublicKeyByID(keyID int64) (*PublicKey, error) { return key, nil } -// SearchPublicKeyByContent searches content as prefix (leak e-mail part) -// and returns public key found. -func SearchPublicKeyByContent(content string) (*PublicKey, error) { +func searchPublicKeyByContentWithEngine(e Engine, content string) (*PublicKey, error) { key := new(PublicKey) - has, err := x. + has, err := e. Where("content like ?", content+"%"). Get(key) if err != nil { @@ -466,6 +464,12 @@ func SearchPublicKeyByContent(content string) (*PublicKey, error) { return key, nil } +// SearchPublicKeyByContent searches content as prefix (leak e-mail part) +// and returns public key found. +func SearchPublicKeyByContent(content string) (*PublicKey, error) { + return searchPublicKeyByContentWithEngine(x, content) +} + // SearchPublicKey returns a list of public keys matching the provided arguments. func SearchPublicKey(uid int64, fingerprint string) ([]*PublicKey, error) { keys := make([]*PublicKey, 0, 5) |