mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-24 13:43:12 +02:00
Use the right single user ID on the WS implementation
This commit is contained in:
parent
fcf4ed49b2
commit
5f963af701
@ -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 ""
|
||||
}
|
||||
|
@ -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))
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user