diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-02-25 18:30:48 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-02-25 18:30:48 +0800 |
commit | 52984f85d5afc2a74bb3ca04487da7fb277437d6 (patch) | |
tree | be3843f3270c679a01432b86f36b7887d1906398 /routers | |
parent | d42c194aadd349ebb2e87d64d764a370fb3f54dc (diff) | |
download | gitea-52984f85d5afc2a74bb3ca04487da7fb277437d6.tar.gz gitea-52984f85d5afc2a74bb3ca04487da7fb277437d6.zip |
add publickey
Diffstat (limited to 'routers')
-rw-r--r-- | routers/user/ssh.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/routers/user/ssh.go b/routers/user/ssh.go index 84f41150ff..c7fae4b4b8 100644 --- a/routers/user/ssh.go +++ b/routers/user/ssh.go @@ -21,9 +21,16 @@ func AddPublickKey(req *http.Request, r render.Render) { return } - k := &models.PublicKey{} - err := models.AddPublicKey(k, "") - r.HTML(403, "status/403", map[string]interface{}{ - "Title": fmt.Sprintf("%v", err), - }) + k := &models.PublicKey{OwnerId: 1, + Name: req.FormValue("keyname"), + Content: req.FormValue("key_content"), + } + err := models.AddPublicKey(k) + if err != nil { + r.HTML(403, "status/403", map[string]interface{}{ + "Title": fmt.Sprintf("%v", err), + }) + } else { + r.HTML(200, "user/publickey_added", map[string]interface{}{}) + } } |