mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
Fix affiliationMap null bug.
This commit is contained in:
@ -23,7 +23,10 @@ func (syncer *Syncer) syncUsers() {
|
||||
oUsers, oUserMap := syncer.getOriginalUserMap()
|
||||
fmt.Printf("Users: %d, oUsers: %d\n", len(users), len(oUsers))
|
||||
|
||||
_, affiliationMap := syncer.getAffiliationMap()
|
||||
var affiliationMap map[int]string
|
||||
if syncer.AffiliationTable != "" {
|
||||
_, affiliationMap = syncer.getAffiliationMap()
|
||||
}
|
||||
|
||||
newUsers := []*User{}
|
||||
for _, oUser := range oUsers {
|
||||
|
@ -43,26 +43,35 @@ func (syncer *Syncer) getPartialAvatarUrl(avatar string) string {
|
||||
func (syncer *Syncer) createUserFromOriginalUser(originalUser *OriginalUser, affiliationMap map[int]string) *User {
|
||||
user := *originalUser
|
||||
user.Owner = syncer.Organization
|
||||
|
||||
if user.Name == "" {
|
||||
user.Name = originalUser.Id
|
||||
}
|
||||
|
||||
if user.CreatedTime == "" {
|
||||
user.CreatedTime = util.GetCurrentTime()
|
||||
}
|
||||
|
||||
if user.Type == "" {
|
||||
user.Type = "normal-user"
|
||||
}
|
||||
|
||||
user.Avatar = syncer.getFullAvatarUrl(user.Avatar)
|
||||
if originalUser.Score != 0 {
|
||||
affiliation, ok := affiliationMap[originalUser.Score]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("Affiliation not found: %d", originalUser.Score))
|
||||
|
||||
if affiliationMap != nil {
|
||||
if originalUser.Score != 0 {
|
||||
affiliation, ok := affiliationMap[originalUser.Score]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("Affiliation not found: %d", originalUser.Score))
|
||||
}
|
||||
user.Affiliation = affiliation
|
||||
}
|
||||
user.Affiliation = affiliation
|
||||
}
|
||||
|
||||
if user.Properties == nil {
|
||||
user.Properties = map[string]string{}
|
||||
}
|
||||
|
||||
return &user
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user