bito-code-review[bot] commented on code in PR #44456:
URL: https://github.com/apache/superset/pull/44456#discussion_r4055490191


##########
superset-frontend/src/pages/Home/index.tsx:
##########
@@ -448,4 +450,17 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
   );
 }
 
-export default withToasts(Welcome);
+function WelcomePage(props: WelcomeProps) {
+  const hasUserId = Boolean(props.user?.userId);
+
+  useEffect(() => {
+    if (!hasUserId) {
+      // SPA navigation can bypass the welcome view's server-side login check.
+      redirect(RoutePaths.HOME);
+    }
+  }, [hasUserId]);
+
+  return hasUserId ? <Welcome {...props} /> : null;

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Type contract mismatch</b></div>
   <div id="fix">
   
   `WelcomeProps.user` is declared required, yet `WelcomePage` guards 
`props.user?.userId` and the test passes `undefined`. The wrapper's real 
contract (user may be absent) contradicts the type. Type `WelcomePage`'s props 
with `user?` so the guard is type-honest and `Welcome`'s `userid!.toString()` 
stays guarded.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #892167</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to