1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

finish ssh key pages ui

This commit is contained in:
FuXiaoHei
2014-03-10 21:12:49 +08:00
parent 3ca7a33907
commit efa039a0f7
6 changed files with 82 additions and 6 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/martini-contrib/render"
"github.com/martini-contrib/sessions"
"net/http"
"strconv"
)
func Setting(r render.Render, data base.TmplData, session sessions.Session) {
@@ -21,6 +22,37 @@ func Setting(r render.Render, data base.TmplData, session sessions.Session) {
}
func SettingSSHKeys(r render.Render, data base.TmplData, req *http.Request, session sessions.Session) {
// del ssh ky
if req.Method == "DELETE" || req.FormValue("_method") == "DELETE" {
id, err := strconv.ParseInt(req.FormValue("id"), 10, 64)
if err != nil {
data["ErrorMsg"] = err
log.Error("ssh.DelPublicKey: %v", err)
r.JSON(200, map[string]interface{}{
"ok": false,
"err": err.Error(),
})
return
}
k := &models.PublicKey{
Id: id,
OwnerId: auth.SignedInId(session),
}
err = models.DeletePublicKey(k)
if err != nil {
data["ErrorMsg"] = err
log.Error("ssh.DelPublicKey: %v", err)
r.JSON(200, map[string]interface{}{
"ok": false,
"err": err.Error(),
})
} else {
r.JSON(200, map[string]interface{}{
"ok": true,
})
}
return
}
// add ssh key
if req.Method == "POST" {
k := &models.PublicKey{OwnerId: auth.SignedInId(session),