diff options
author | Unknwon <u@gogs.io> | 2015-08-20 17:11:29 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-20 17:11:29 +0800 |
commit | 062adbed8a8a9cb83cd172b5a6e232e75af89f2d (patch) | |
tree | 07a35a3c9dca8d1be54614b006b7c0487a9cdb62 /models/publickey.go | |
parent | 9b01a3501b8c1897a9c02bf82dcc169a20b9a51f (diff) | |
download | gitea-062adbed8a8a9cb83cd172b5a6e232e75af89f2d.tar.gz gitea-062adbed8a8a9cb83cd172b5a6e232e75af89f2d.zip |
add confirmation to delete ssh key
Diffstat (limited to 'models/publickey.go')
-rw-r--r-- | models/publickey.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/models/publickey.go b/models/publickey.go index 400486eba7..e5516526bc 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -466,7 +466,15 @@ func deletePublicKey(e *xorm.Session, key *PublicKey) error { } // DeletePublicKey deletes SSH key information both in database and authorized_keys file. -func DeletePublicKey(key *PublicKey) (err error) { +func DeletePublicKey(id int64) (err error) { + key := &PublicKey{ID: id} + has, err := x.Id(key.ID).Get(key) + if err != nil { + return err + } else if !has { + return nil + } + sess := x.NewSession() defer sessionRelease(sess) if err = sess.Begin(); err != nil { |