1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-12-04 14:46:57 -05:00

Mirror fix on add ssh key

This commit is contained in:
Unknwon 2014-10-11 21:04:42 -04:00
parent fb839ca0fb
commit 452ccff81c
4 changed files with 12 additions and 4 deletions

View File

@ -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.

View File

@ -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 = 您的帐户仍然是某些仓库的拥有者,您必须先转移或删除它们才能执行删除帐户操作!

View File

@ -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.

View File

@ -177,10 +177,14 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
cleanContent := strings.Replace(form.Content, "\n", "", -1)
if ok, err := models.CheckPublicKeyString(cleanContent); !ok {
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{
OwnerId: ctx.User.Id,