summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-10-11 21:04:42 -0400
committerUnknwon <joe2010xtmf@163.com>2014-10-11 21:04:42 -0400
commit452ccff81ca736a07bec44a059a0562a08656bf4 (patch)
tree15487dbe076319793515a34586991753a2ef34cd
parentfb839ca0fb998f2dfdd280e959f85a576bb7742b (diff)
downloadgitea-452ccff81ca736a07bec44a059a0562a08656bf4.tar.gz
gitea-452ccff81ca736a07bec44a059a0562a08656bf4.zip
Mirror fix on add ssh key
-rw-r--r--conf/locale/locale_en-US.ini1
-rw-r--r--conf/locale/locale_zh-CN.ini1
-rw-r--r--models/publickey.go4
-rw-r--r--routers/user/setting.go10
4 files changed, 12 insertions, 4 deletions
diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini
index e0a5066503..f99a9e7285 100644
--- a/conf/locale/locale_en-US.ini
+++ b/conf/locale/locale_en-US.ini
@@ -159,6 +159,7 @@ user_not_exist = Given user does not exist.
last_org_owner = The user to remove is the last member in owner team. There must be another owner.
invalid_ssh_key = Sorry, we're not able to verify your SSH key: %s
+unable_verify_ssh_key = Gogs cannot verify your SSH key, but we assume that is valid, please make sure yourself.
auth_failed = Authentication failed: %v
still_own_repo = Your account still have ownership of repository, you have to delete or transfer them first.
diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini
index c704ad2051..0c17f2d7f9 100644
--- a/conf/locale/locale_zh-CN.ini
+++ b/conf/locale/locale_zh-CN.ini
@@ -159,6 +159,7 @@ user_not_exist = 被操作的用户不存在!
last_org_owner = 被移除用户为最后一位管理员。请添加一位新的管理员再进行移除成员操作!
invalid_ssh_key = 很抱歉,我们无法验证您输入的 SSH 密钥:%s
+unable_verify_ssh_key = Gogs 无法验证您输入的 SSH 密钥,但我们假设那是有效的密钥,请您自行确保其有效性!
auth_failed = 授权验证失败:%v
still_own_repo = 您的帐户仍然是某些仓库的拥有者,您必须先转移或删除它们才能执行删除帐户操作!
diff --git a/models/publickey.go b/models/publickey.go
index aac5a81aeb..762d7333fa 100644
--- a/models/publickey.go
+++ b/models/publickey.go
@@ -33,6 +33,7 @@ const (
var (
ErrKeyAlreadyExist = errors.New("Public key already exist")
ErrKeyNotExist = errors.New("Public key does not exist")
+ ErrKeyUnableVerify = errors.New("Unable to verify public key")
)
var sshOpLocker = sync.Mutex{}
@@ -134,9 +135,10 @@ func CheckPublicKeyString(content string) (bool, error) {
return true, nil
}
+ fmt.Println(stdout)
sshKeygenOutput := strings.Split(stdout, " ")
if len(sshKeygenOutput) < 4 {
- return false, fmt.Errorf("not enough fields returned by ssh-keygen -l -f: %v", sshKeygenOutput)
+ return false, ErrKeyUnableVerify
}
// Check if key type and key size match.
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 8f778acd0d..778f27ac50 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -177,9 +177,13 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
cleanContent := strings.Replace(form.Content, "\n", "", -1)
if ok, err := models.CheckPublicKeyString(cleanContent); !ok {
- ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error()))
- ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh")
- return
+ if err == models.ErrKeyUnableVerify {
+ ctx.Flash.Info(ctx.Tr("form.unable_verify_ssh_key"))
+ } else {
+ ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error()))
+ ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh")
+ return
+ }
}
k := &models.PublicKey{