fix: auth plugin, plugins purchased via razorpay, formatting and othe…#2066
fix: auth plugin, plugins purchased via razorpay, formatting and othe…#2066deadlyjack wants to merge 8 commits intomainfrom
Conversation
…r fixes - Refactored the WebSocket plugin implementation in websocket.js for improved readability and consistency. - Changed import statements in multiple settings files to use 'config' instead of 'constants' for better configuration management. - Updated URLs in settings and sidebarApps to use the new config structure. - Fixed a typo in sidebarApp.js variable name from $contaienr to $container. - Enhanced the canShowAds method in helpers.js to utilize the new config for checking the ad display conditions.
|
@greptile_apps review |
Greptile SummaryThis PR centralises configuration into a new
Confidence Score: 2/5Not safe to merge — two P0/P1 regressions break core user-facing flows for all logged-in users A P0 ( src/components/sidebar/index.js (undefined Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant S as Sidebar (handleUserIconClick)
participant A as auth.getLoggedInUser()
participant C as config.BASE_URL
U->>S: clicks user icon
S->>A: await auth.getLoggedInUser()
alt user is null (not logged in)
A-->>S: null
S->>C: CustomTabs.open(config.BASE_URL + /login)
else user is logged in
A-->>S: user object
S->>S: toggle menu active
Note over S: ReferenceError: userInfo is not defined
end
participant AR as adRewards (getRewardIdentity)
participant AD as createRewardedAd
U->>AR: watchOffer(offerId)
AR->>AR: getRewardIdentity()
Note over AR: user undeclared, ReferenceError caught
AR->>AD: createRewardedAd(offer, step, sessionId)
Note over AD: serverSideVerification.userId = undefined
Reviews (3): Last reviewed commit: "refactor: streamline user menu toggle lo..." | Re-trigger Greptile |
| if (res.ok) { | ||
| userContextMenu.el.classList.remove("active"); | ||
| document.removeEventListener("click", handleClickOutside); | ||
| toast("Logged out successfully"); | ||
| updateSidebarAvatar(); |
There was a problem hiding this comment.
Undefined variables cause silent ReferenceError on logout
userContextMenu, handleClickOutside, and updateSidebarAvatar are not defined in auth.js — they live in src/components/sidebar/index.js. When the API logout succeeds (res.ok), this code throws a ReferenceError that is immediately caught and swallowed by the catch block (line 90). The dead block should be removed — auth.logout() should only own the server-side and native token teardown, not presentation logic.
| @@ -68,19 +68,12 @@ export default async function installPlugin( | |||
|
|
|||
| let plugin; | |||
| if ( | |||
| pluginUrl.includes(constants.API_BASE) || | |||
| pluginUrl.includes(config.API_BASE) || | |||
| pluginUrl.startsWith("file:") || | |||
| pluginUrl.startsWith("content:") | |||
| ) { | |||
| // Use fsOperation for Acode registry URL | |||
There was a problem hiding this comment.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
@greptile_apps review again |
| async function updateUserMenuInfo() { | ||
| try { | ||
| const userInfo = await auth.getUserInfo(); | ||
| if (userInfo) { | ||
| const menuName = userContextMenu.el.querySelector(".user-menu-name"); | ||
| const menuEmail = userContextMenu.el.querySelector(".user-menu-email"); | ||
| menuName.textContent = userInfo.name || "Anonymous"; | ||
| if (userInfo.isAdmin) { | ||
| menuName.innerHTML += ' <span class="badge">Admin</span>'; | ||
| } | ||
| menuEmail.textContent = userInfo.email || ""; | ||
| } | ||
| const userInfo = await auth.getLoggedInUser(); | ||
| const menuName = userContextMenu.el.querySelector(".user-menu-name"); | ||
| const menuEmail = userContextMenu.el.querySelector(".user-menu-email"); | ||
| menuName.content = ( | ||
| <div style={{ display: "flex" }}> | ||
| {Boolean(userInfo.verified) && ( | ||
| <span className="icon verified"></span> | ||
| )} | ||
| {userInfo.name} | ||
| {Boolean(userInfo.acode_pro) && <span className="badge">Pro</span>} | ||
| </div> | ||
| ); | ||
| menuEmail.textContent = userInfo.email || ""; | ||
| } catch (error) { | ||
| console.error("Error fetching user info:", error); | ||
| } |
There was a problem hiding this comment.
Null dereference in
updateUserMenuInfo when getLoggedInUser() returns null
auth.getLoggedInUser() explicitly returns null when the server responds with 401 (e.g., session expired between the handleUserIconClick guard and this call, or the token was revoked). Accessing userInfo.verified, userInfo.name, userInfo.acode_pro, and userInfo.email on a null value all throw TypeError. The catch block swallows the error silently, so the menu is rendered empty with no user feedback.
Add a null guard after the await:
const userInfo = await auth.getLoggedInUser();
if (!userInfo) return;|
@greptile_apps review again |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
fix: clear loggedInUser and remove cached user data on logout
…r fixes