summaryrefslogtreecommitdiffstats
path: root/store/sql_session_store.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-08-17 09:28:20 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-17 09:28:20 -0400
commitb068cc1058a2909e7fc9d9622e806d52127bfa52 (patch)
tree0670b4f8fc4c7afd97c785728a79736138a40445 /store/sql_session_store.go
parente5a38174884310a07e62bed99e10b655c5c6749f (diff)
downloadchat-b068cc1058a2909e7fc9d9622e806d52127bfa52.tar.gz
chat-b068cc1058a2909e7fc9d9622e806d52127bfa52.tar.bz2
chat-b068cc1058a2909e7fc9d9622e806d52127bfa52.zip
when user roles are updated, the relevant session roles are updated as well
Diffstat (limited to 'store/sql_session_store.go')
-rw-r--r--store/sql_session_store.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/store/sql_session_store.go b/store/sql_session_store.go
index d1a06a33c..12004ab78 100644
--- a/store/sql_session_store.go
+++ b/store/sql_session_store.go
@@ -175,3 +175,22 @@ func (me SqlSessionStore) UpdateLastActivityAt(sessionId string, time int64) Sto
return storeChannel
}
+
+func (me SqlSessionStore) UpdateRoles(userId, roles string) StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ if _, err := me.GetMaster().Exec("UPDATE Sessions SET Roles = :Roles WHERE UserId = :UserId", map[string]interface{}{"Roles": roles, "UserId": userId}); err != nil {
+ result.Err = model.NewAppError("SqlSessionStore.UpdateRoles", "We couldn't update the roles", "userId="+userId)
+ } else {
+ result.Data = userId
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}