LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576647590
##########
web-v2/web/src/app/page.js:
##########
@@ -19,6 +19,16 @@
'use client'
+import { useEffect } from 'react'
+
+import { useRouter } from 'next/navigation'
+
export default function Home() {
- return <></>
+ const router = useRouter()
+
+ useEffect(() => {
+ router.replace('/metalakes')
Review Comment:
The initAuth function in session.js already fully covers the redirect logic
for all authType values:
* simple: Unauthenticated → /login; Authenticated → goToMetalakeListPage() →
/metalakes
* basic: No token → /login; Has token → goToMetalakeListPage() → /metalakes
* oauth: No token → /login; Has token → goToMetalakeListPage() → /metalakes
The goToMetalakeListPage() function (defined at session.js:54-70) already
executes router.replace('/metalakes') when the current pathname is /.
Since AuthProvider wraps all pages in layout.js, when a user visits the root
path /:
1. AuthProvider's useEffect triggers initAuth, which handles the redirect
based on auth state
2. page.js's useEffect also triggers router.replace('/metalakes')
These two redirects execute simultaneously, making the one in page.js
completely redundant — it is entirely covered by initAuth's logic.
Conclusion: The router.replace('/metalakes') in page.js is unnecessary and
can be safely removed, as initAuth already handles all redirect scenarios for
every authType.
--
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]