fix(auth): propagate secure token request failures#1142
fix(auth): propagate secure token request failures#1142Shreyas2004wagh wants to merge 2 commits intoRocketChat:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes secure-auth token flows so request failures properly reject instead of being silently swallowed, improving error handling across @embeddedchat/auth and the React wrapper that wires token storage into the auth stack.
Changes:
- Rethrow errors in
tokenRequestHandlerafter logging so callers can handle real request failures. - Make secure token save/delete helpers return the
handleSecureLoginpromise so failures propagate to callers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/react/src/lib/auth.js | Ensures secure save/delete token helpers return a promise so errors can propagate up the auth flow. |
| packages/auth/src/utils/tokenRequestHandler.ts | Rethrows caught errors so secure token HTTP failures are not converted into implicit undefined success. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async function saveTokenSecure(token) { | ||
| this.handleSecureLogin('save', token); | ||
| return await this.handleSecureLogin('save', token); | ||
| } |
There was a problem hiding this comment.
return await is redundant here and will likely violate Airbnb ESLint's no-return-await rule. Since this function is already async, you can return the promise from handleSecureLogin directly to propagate rejections while avoiding the lint error.
| async function deleteTokenSecure() { | ||
| this.handleSecureLogin('delete'); | ||
| return await this.handleSecureLogin('delete'); | ||
| } |
There was a problem hiding this comment.
Same as above: return await is redundant and may trigger the Airbnb ESLint no-return-await rule. Return the handleSecureLogin promise directly so errors still propagate without introducing a lint failure.
Fix secure token error propagation in auth helpers
Acceptance Criteria fulfillment
tokenRequestHandlerno longer swallows request failures.@embeddedchat/auth,@embeddedchat/react).Fixes #1141
Video/Screenshots
N/A (logic-only change)
PR Test Details
yarn lerna run build --scope @embeddedchat/auth --scope @embeddedchat/react✅tokenRequestHandlerrethrows incatch