-
Notifications
You must be signed in to change notification settings - Fork 2
fix(iam): integrate current user data into profile page, enforce email verification redirect, and update logout flow in verify-email page #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ export default function DashboardLayout({ | |
| }: { | ||
| children: React.ReactNode | ||
| }) { | ||
| const { isAuthenticated, isLoading } = useAuth() | ||
| const { isAuthenticated, isLoading, user } = useAuth() | ||
| const router = useRouter() | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -60,6 +60,13 @@ export default function DashboardLayout({ | |
| } | ||
| }, [isLoading, isAuthenticated, router]) | ||
|
|
||
| // Redirect to email verification if authenticated but email not verified | ||
| useEffect(() => { | ||
| if (!isLoading && isAuthenticated && user && user.emailVerified === false) { | ||
| router.push("/verify-email") | ||
| } | ||
| }, [isLoading, isAuthenticated, user, router]) | ||
|
Comment on lines
+63
to
+68
|
||
|
|
||
| // Show skeleton while checking auth | ||
| if (isLoading) { | ||
| return <DashboardSkeleton /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { ActivityLogInline } from "@/components/settings/activity-log-inline" | |||||
| import { ProfileEditForm } from "@/components/settings/profile-edit-form" | ||||||
| import { cn } from "@/lib/utils" | ||||||
| import { useQueryClient } from "@tanstack/react-query" | ||||||
| import { currentUserKeys } from "@/hooks/iam/use-current-user" | ||||||
| import { currentUserKeys, useCurrentUser } from "@/hooks/iam/use-current-user" | ||||||
| import { | ||||||
| User, | ||||||
| KeyRound, | ||||||
|
|
@@ -32,12 +32,15 @@ const sidebarItems: { id: TabValue; label: string; icon: React.ElementType }[] = | |||||
|
|
||||||
| export default function ProfilePage() { | ||||||
| const queryClient = useQueryClient() | ||||||
| const { data: userProfile, isLoading, error } = useUserProfile() | ||||||
| const { data: userProfile, isLoading: isProfileLoading } = useUserProfile() | ||||||
| const { data: currentUser, isLoading: isCurrentUserLoading } = useCurrentUser() | ||||||
| const [activeTab, setActiveTab] = useState<TabValue>("general") | ||||||
| const [twoFactorEnabled, setTwoFactorEnabled] = useState<boolean | undefined>(undefined) | ||||||
|
|
||||||
| const isLoading = isProfileLoading && isCurrentUserLoading | ||||||
|
||||||
| const isLoading = isProfileLoading && isCurrentUserLoading | |
| const isLoading = isProfileLoading || isCurrentUserLoading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The button label says "Back to login", but calling
logout()will navigate to/(seeAuthProvider.logout()), not toAUTH_ROUTES.LOGIN. This changes behavior from the previousLinkto the login page and can confuse users; either redirect to the login route after logout (or adjustlogoutto support a caller-provided redirect) or update the label to match the actual destination.