summaryrefslogtreecommitdiffstats
path: root/models/publickey.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-20 17:11:29 +0800
committerUnknwon <u@gogs.io>2015-08-20 17:11:29 +0800
commit062adbed8a8a9cb83cd172b5a6e232e75af89f2d (patch)
tree07a35a3c9dca8d1be54614b006b7c0487a9cdb62 /models/publickey.go
parent9b01a3501b8c1897a9c02bf82dcc169a20b9a51f (diff)
downloadgitea-062adbed8a8a9cb83cd172b5a6e232e75af89f2d.tar.gz
gitea-062adbed8a8a9cb83cd172b5a6e232e75af89f2d.zip
add confirmation to delete ssh key
Diffstat (limited to 'models/publickey.go')
-rw-r--r--models/publickey.go10
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 {