Bug: Incomplete logout leaves UI stuck in authenticated state when channel is missing or access is denied in ChatHeader.js

未关闭
#1,427 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@yashsarvaiya45 已经在做这个了。

开始于 2026年11月15日。

  • #1428 来自 @yashsarvaiya45 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
javascript, react
领域
frontend

调研方向

Start in packages/react/src/views/ChatHeader/ChatHeader.js at getChannelInfo (lines 202–288) and compare its two error branches with handleLogout() in the same file, noting which state resets are skipped. Also inspect the unguarded RCInstance.channelInfo() and setMessageAllowed paths. Done means both error branches reach the logout state reset and null/rejected responses are handled; verify by authenticating with a non-existent roomId. A linked open pull request (#1428) already covers this work, so read it before starting.

由索引模型根据 Issue 内容生成。

描述

Description

In packages/react/src/views/ChatHeader/ChatHeader.js, when getChannelInfo encounters an 'error-room-not-found' or 'Not Allowed' error, it dispatches an error toast ("Logging out") and calls await RCInstance.logout() directly instead of invoking handleLogout().

Because handleLogout() is bypassed:

  1. setIsUserAuthenticated(false) is never called, leaving the React UI permanently stuck in the authenticated view even though the backend session has been terminated.
  2. Stores and UI state (setMessages([]), setChannelInfo({}), setShowSidebar(false), setUserAvatarUrl(null), and isMessageLoaded) are not reset.
  3. Additionally, getChannelInfo and setMessageAllowed lack try...catch blocks and safe optional chaining (res?.success, res && 'errorType' in res), which can cause an unhandled TypeError crash if RCInstance.channelInfo() returns undefined or rejects on network failure.
Affected File
  • packages/react/src/views/ChatHeader/ChatHeader.js (lines 202–288)
Steps to Reproduce
  1. Authenticate into EmbeddedChat configured with a non-existent roomId (error-room-not-found) or a restricted private room where the user lacks permission (Not Allowed).
  2. Observe the toast message: "Channel doesn't exist. Logging out." or "You don't have permission to access this channel. Logging out".
  3. Notice that while RCInstance.logout() runs, isUserAuthenticated remains true and the UI stays stuck in the logged-in state instead of returning to the login state.
Expected Behavior
  • Error-triggered logouts in getChannelInfo should call await handleLogout() so that isUserAuthenticated is set to false and all user/channel/message stores are properly cleared.
  • Async calls in getChannelInfo and setMessageAllowed should safely guard against null/undefined responses and network rejections.
主要语言
JavaScript
星标
170
派生
397
平均合并
12 天 14 小时
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RocketChat/EmbeddedChat 的其他 Issue

查看 RocketChat/EmbeddedChat 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。