1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-24 08:22:29 +02:00

Merge pull request #2760 from mattermost/single-user-mode-not-refreshing-correctly

Use the right single user ID on the WS implementation
This commit is contained in:
Scott Bishel 2022-04-11 11:53:36 -06:00 committed by GitHub
commit 0355e1c7d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -14,8 +14,6 @@ import (
"github.com/mattermost/mattermost-server/v6/shared/mlog"
)
const singleUserID = "single-user-id"
func (wss *websocketSession) WriteJSON(v interface{}) error {
wss.mu.Lock()
defer wss.mu.Unlock()
@ -224,7 +222,7 @@ func (ws *Server) handleWebSocket(w http.ResponseWriter, r *http.Request) {
// if single user mode, check that the userID is valid and
// assume that the user has permission if so
if len(ws.singleUserToken) != 0 {
if wsSession.userID != singleUserID {
if wsSession.userID != model.SingleUser {
continue
}
@ -426,7 +424,7 @@ func (ws *Server) removeListenerFromBlock(listener *websocketSession, blockID st
func (ws *Server) getUserIDForToken(token string) string {
if len(ws.singleUserToken) > 0 {
if token == ws.singleUserToken {
return singleUserID
return model.SingleUser
} else {
return ""
}

View File

@ -5,6 +5,7 @@ import (
"testing"
"github.com/mattermost/focalboard/server/auth"
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
@ -235,6 +236,6 @@ func TestGetUserIDForTokenInSingleUserMode(t *testing.T) {
})
t.Run("Should return the single user ID if the token is correct", func(t *testing.T) {
require.Equal(t, singleUserID, server.getUserIDForToken(singleUserToken))
require.Equal(t, model.SingleUser, server.getUserIDForToken(singleUserToken))
})
}