diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-08-09 15:40:10 -0700 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-08-09 15:40:10 -0700 |
commit | 9a1d5d2489d25778e26ab413cb9ee78d3fe2823a (patch) | |
tree | 4e31de40d92b96ba9fa8f45e5da442291303832e /models/publickey.go | |
parent | 9820b8e1342017edfe4f6ced9cc3a7d811449c7b (diff) | |
download | gitea-9a1d5d2489d25778e26ab413cb9ee78d3fe2823a.tar.gz gitea-9a1d5d2489d25778e26ab413cb9ee78d3fe2823a.zip |
Finish new web hook pages
Diffstat (limited to 'models/publickey.go')
-rw-r--r-- | models/publickey.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/models/publickey.go b/models/publickey.go index f9880c74cd..1246cffc58 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -209,6 +209,18 @@ func AddPublicKey(key *PublicKey) (err error) { return nil } +// GetPublicKeyById returns public key by given ID. +func GetPublicKeyById(keyId int64) (*PublicKey, error) { + key := new(PublicKey) + has, err := x.Id(keyId).Get(key) + if err != nil { + return nil, err + } else if !has { + return nil, ErrKeyNotExist + } + return key, nil +} + // ListPublicKey returns a list of all public keys that user has. func ListPublicKey(uid int64) ([]*PublicKey, error) { keys := make([]*PublicKey, 0, 5) @@ -277,6 +289,12 @@ func rewriteAuthorizedKeys(key *PublicKey, p, tmpP string) error { return nil } +// UpdatePublicKey updates given public key. +func UpdatePublicKey(key *PublicKey) error { + _, err := x.Id(key.Id).AllCols().Update(key) + return err +} + // DeletePublicKey deletes SSH key information both in database and authorized_keys file. func DeletePublicKey(key *PublicKey) error { has, err := x.Get(key) |