1
0
Fork 0
forked from forgejo/forgejo

Finish new web hook pages

This commit is contained in:
Unknwon 2014-08-09 15:40:10 -07:00
parent 9820b8e134
commit 9a1d5d2489
23 changed files with 249 additions and 265 deletions

View file

@ -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)