Skip to content

Commit

Permalink
Fix empty ssh key importing in ldap (go-gitea#5984)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeripath committed Feb 8, 2019
1 parent d269179 commit c89d66a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -1461,9 +1461,12 @@ func synchronizeLdapSSHPublicKeys(usr *User, s *LoginSource, SSHPublicKeys []str
// Get Public Keys from LDAP and skip duplicate keys
var ldapKeys []string
for _, v := range SSHPublicKeys {
ldapKey := strings.Join(strings.Split(v, " ")[:2], " ")
if !util.ExistsInSlice(ldapKey, ldapKeys) {
ldapKeys = append(ldapKeys, ldapKey)
sshKeySplit := strings.Split(v, " ")
if len(sshKeySplit) > 1 {
ldapKey := strings.Join(sshKeySplit[:2], " ")
if !util.ExistsInSlice(ldapKey, ldapKeys) {
ldapKeys = append(ldapKeys, ldapKey)
}
}
}

Expand Down

0 comments on commit c89d66a

Please sign in to comment.