bito-code-review[bot] commented on code in PR #44456:
URL: https://github.com/apache/superset/pull/44456#discussion_r4059711325
##########
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:
<!-- Bito Reply -->
The implementation correctly addresses the requirement by narrowing the user
prop within the component, ensuring type safety while maintaining the necessary
runtime guard. Keeping the literal route assertion in the test is appropriate,
as it enforces the server-side contract and prevents silent divergence if the
route constant is modified.
**superset-frontend/src/pages/Home/index.tsx**
```
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;
```
--
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]