Merge pull request #8238 from swordqiu/hotfix/qj-ldap-sync-not-update-email-phone

fix: ldap sync not update user's phone and email
This commit is contained in:
yunion-ci-robot
2020-10-12 11:54:19 +08:00
committed by GitHub
3 changed files with 7 additions and 3 deletions
@@ -145,6 +145,8 @@ func syncScopeResourceCount(ctx context.Context, regionId string, serviceId stri
ownerList = append(ownerList, scopeRes.OwnerId)
}
scopeRes.SetModelManager(models.ScopeResourceManager, &scopeRes)
err := models.ScopeResourceManager.TableSpec().InsertOrUpdate(ctx, &scopeRes)
if err != nil {
log.Errorf("table insert error %s", err)
+3 -3
View File
@@ -241,13 +241,13 @@ func (self *SLDAPDriver) syncUserDB(ctx context.Context, ui SUserInfo, domainId
// } else {
// user.Enabled = tristate.False
// }
if val, ok := ui.Extra["email"]; ok && len(val) > 0 && len(user.Email) > 0 {
if val, ok := ui.Extra["email"]; ok && len(val) > 0 && len(user.Email) == 0 {
user.Email = val
}
if val, ok := ui.Extra["displayname"]; ok && len(val) > 0 && len(user.Displayname) > 0 {
if val, ok := ui.Extra["displayname"]; ok && len(val) > 0 && len(user.Displayname) == 0 {
user.Displayname = val
}
if val, ok := ui.Extra["mobile"]; ok && len(val) > 0 && len(user.Mobile) > 0 {
if val, ok := ui.Extra["mobile"]; ok && len(val) > 0 && len(user.Mobile) == 0 {
user.Mobile = val
}
})
+2
View File
@@ -19,6 +19,7 @@ import (
"net/http"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/sqlchemy"
@@ -222,6 +223,7 @@ func verifyCommon(ctx context.Context, w http.ResponseWriter, tokenStr string) (
token := SAuthToken{}
err := token.ParseFernetToken(tokenStr)
if err != nil {
log.Errorf("ParseFernetToken %s fail: %s", tokenStr, err)
return nil, httperrors.NewInvalidCredentialError("invalid token")
}
return &token, nil