aboutsummaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-02-07 02:38:28 +0000
committertechknowlogick <matti@mdranta.net>2019-02-06 21:38:28 -0500
commitcc48c12d8f16dcb10b21972f7bfd631c5d15be48 (patch)
tree916b1dcb42e5712b6f1a212f549aa8963ee28c0b /models/user.go
parent44d6a904d3c2e54c68759f062b28a626fd9f9254 (diff)
downloadgitea-cc48c12d8f16dcb10b21972f7bfd631c5d15be48.tar.gz
gitea-cc48c12d8f16dcb10b21972f7bfd631c5d15be48.zip
Fix empty ssh key importing in ldap (#5984)
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/models/user.go b/models/user.go
index 5eb9db1e5e..e50385d411 100644
--- a/models/user.go
+++ b/models/user.go
@@ -1501,9 +1501,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)
+ }
}
}