summaryrefslogtreecommitdiffstats
path: root/mattermost.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-05-27 09:56:26 -0700
committerChristopher Speller <crspeller@gmail.com>2016-05-27 12:56:26 -0400
commitcb745475452a9fc8ef3a9fedf6b34af7d05adba9 (patch)
tree2aff9e035b8ccfc54b1c3c2785b2cae719923592 /mattermost.go
parent40743af734e438a97f946476552ccda2a5b0dbcf (diff)
downloadchat-cb745475452a9fc8ef3a9fedf6b34af7d05adba9.tar.gz
chat-cb745475452a9fc8ef3a9fedf6b34af7d05adba9.tar.bz2
chat-cb745475452a9fc8ef3a9fedf6b34af7d05adba9.zip
PLT-3063 fix upgrade when user is a team admin (#3127)
Diffstat (limited to 'mattermost.go')
-rw-r--r--mattermost.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/mattermost.go b/mattermost.go
index 6fe285d58..6073f37f4 100644
--- a/mattermost.go
+++ b/mattermost.go
@@ -483,6 +483,7 @@ func convertTeamTo30(primaryTeamName string, team *TeamForUpgrade, uniqueEmails
for _, user := range users {
shouldUpdateUser := false
+ shouldUpdateRole := false
previousRole := user.Roles
previousEmail := user.Email
previousUsername := user.Username
@@ -495,7 +496,7 @@ func convertTeamTo30(primaryTeamName string, team *TeamForUpgrade, uniqueEmails
if model.IsInRole(user.Roles, model.ROLE_TEAM_ADMIN) {
member.Roles = model.ROLE_TEAM_ADMIN
user.Roles = ""
- shouldUpdateUser = true
+ shouldUpdateRole = true
}
exists := false
@@ -609,6 +610,25 @@ func convertTeamTo30(primaryTeamName string, team *TeamForUpgrade, uniqueEmails
}
}
+ if shouldUpdateRole {
+ if _, err := store.GetMaster().Exec(`
+ UPDATE Users
+ SET
+ Roles = ''
+ WHERE
+ Id = :Id
+ `,
+ map[string]interface{}{
+ "Id": user.Id,
+ },
+ ); err != nil {
+ l4g.Error("Failed to update user role %v details=%v", user.Email, err)
+ flushLogAndExit(1)
+ }
+
+ l4g.Info("modified user_id=%v, changed roles from=%v to=%v", user.Id, previousRole, user.Roles)
+ }
+
uniqueEmails[user.Email] = true
uniqueUsernames[user.Username] = true