From b068cc1058a2909e7fc9d9622e806d52127bfa52 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 17 Aug 2015 09:28:20 -0400 Subject: when user roles are updated, the relevant session roles are updated as well --- store/sql_session_store.go | 19 +++++++++++++++++++ store/store.go | 1 + 2 files changed, 20 insertions(+) (limited to 'store') 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 +} diff --git a/store/store.go b/store/store.go index 613fe4198..617ea7f2b 100644 --- a/store/store.go +++ b/store/store.go @@ -99,6 +99,7 @@ type SessionStore interface { GetSessions(userId string) StoreChannel Remove(sessionIdOrAlt string) StoreChannel UpdateLastActivityAt(sessionId string, time int64) StoreChannel + UpdateRoles(userId string, roles string) StoreChannel } type AuditStore interface { -- cgit v1.2.3-1-g7c22