Skip to content

Commit

Permalink
fix joining moderated sessions in ui (#24018)
Browse files Browse the repository at this point in the history
  • Loading branch information
rudream committed Apr 4, 2023
1 parent ffac341 commit f6ddd25
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/web/terminal.go
Expand Up @@ -290,13 +290,6 @@ func (t *TerminalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

// If the displayLogin is set then use it instead of the login name used in
// the SSH connection. This is specifically for the use case when joining
// a session to avoid displaying "-teleport-internal-join" as the username.
if t.displayLogin != "" {
t.sessionData.Login = t.displayLogin
}

sendError := func(errMsg string, err error, ws *websocket.Conn) {
envelope := &Envelope{
Version: defaults.WebsocketVersion,
Expand All @@ -308,7 +301,19 @@ func (t *TerminalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ws.WriteMessage(websocket.BinaryMessage, envelopeBytes)
}

sessionMetadataResponse, err := json.Marshal(siteSessionGenerateResponse{Session: t.sessionData})
var sessionMetadataResponse []byte

// If the displayLogin is set then use it in the session metadata instead of the
// login name used in the SSH connection. This is specifically for the use case
// when joining a session to avoid displaying "-teleport-internal-join" as the username.
if t.displayLogin != "" {
sessionDataTemp := t.sessionData
sessionDataTemp.Login = t.displayLogin
sessionMetadataResponse, err = json.Marshal(siteSessionGenerateResponse{Session: sessionDataTemp})
} else {
sessionMetadataResponse, err = json.Marshal(siteSessionGenerateResponse{Session: t.sessionData})
}

if err != nil {
sendError("unable to marshal session response", err, ws)
return
Expand Down

0 comments on commit f6ddd25

Please sign in to comment.