-
Notifications
You must be signed in to change notification settings - Fork 11
feat(2fa): profile updates and 2fa #128
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d856ac0
refactor(next): extract dashboard shell and centralize auth in layout
gaboesquivel 338f09e
fix(next): auth review - JWT verification, logout cache invalidation,…
gaboesquivel daa654f
refactor(next): remove redundant auth checks in layout and login
gaboesquivel 16d0618
fix(next): auth sign-out response check, jwt decode reuse, proxy refr…
gaboesquivel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| 'use client' | ||
|
|
||
| import { Button } from '@repo/ui/components/button' | ||
| import { SidebarInset, SidebarProvider, SidebarTrigger } from '@repo/ui/components/sidebar' | ||
| import { Toaster } from '@repo/ui/components/sonner' | ||
| import { useQueryClient } from '@tanstack/react-query' | ||
| import { AssistantSidebar } from 'components/assistant' | ||
| import { ApiHealthBadge } from 'components/shared/api-health-badge' | ||
| import { AuthBadge } from 'components/shared/auth-badge' | ||
| import { LogOut } from 'lucide-react' | ||
| import { toast } from 'sonner' | ||
| import { authSessionJwtQueryKey, authSessionUserQueryKey } from '@/lib/query-keys' | ||
|
|
||
| import { PageTitle } from './page-title' | ||
| import { DashboardSidebar } from './sidebar' | ||
|
|
||
| export function DashboardShell({ | ||
| children, | ||
| }: Readonly<{ children: React.ReactNode }>): React.JSX.Element { | ||
| const queryClient = useQueryClient() | ||
|
|
||
| async function handleSignOut() { | ||
| const response = await fetch('/auth/logout', { redirect: 'manual' }) | ||
| const isSuccess = response.status >= 200 && response.status < 400 | ||
| if (!isSuccess) { | ||
| toast.error('Sign out failed. Please try again.') | ||
| return | ||
| } | ||
| queryClient.invalidateQueries({ queryKey: authSessionUserQueryKey }) | ||
| queryClient.invalidateQueries({ queryKey: authSessionJwtQueryKey }) | ||
| window.location.href = '/' | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return ( | ||
| <SidebarProvider> | ||
| <DashboardSidebar /> | ||
| <div className="flex min-w-0 flex-1"> | ||
| <SidebarInset className="flex min-w-0 flex-1 flex-col"> | ||
| <header className="flex h-14 shrink-0 items-center justify-between gap-3 border-b px-4 md:gap-4 md:px-6"> | ||
| <div className="flex min-h-11 items-center md:hidden"> | ||
| <SidebarTrigger className="size-11 shrink-0" /> | ||
| </div> | ||
| <div className="flex min-w-0 flex-1 items-center"> | ||
| <PageTitle /> | ||
| </div> | ||
| <div className="flex min-h-11 items-center gap-3 md:gap-4"> | ||
| <ApiHealthBadge /> | ||
| <AuthBadge /> | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
| className="size-11 sm:size-9" | ||
| aria-label="Sign out" | ||
| type="button" | ||
| onClick={handleSignOut} | ||
| > | ||
| <LogOut /> | ||
| </Button> | ||
| </div> | ||
| </header> | ||
| <div className="flex min-h-0 flex-1" style={{ height: 'calc(100dvh - 3.5rem)' }}> | ||
| <main className="min-w-0 w-0 flex-1 overflow-auto p-4 md:p-6">{children}</main> | ||
| <AssistantSidebar /> | ||
| </div> | ||
| </SidebarInset> | ||
| </div> | ||
| <Toaster richColors position="top-right" /> | ||
| </SidebarProvider> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,7 @@ | ||
| import { Button } from '@repo/ui/components/button' | ||
| import { DashboardShell } from './_dashboard-shell' | ||
|
|
||
| import { SidebarInset, SidebarProvider, SidebarTrigger } from '@repo/ui/components/sidebar' | ||
| import { Toaster } from '@repo/ui/components/sonner' | ||
| import { AssistantSidebar } from 'components/assistant' | ||
| import { ApiHealthBadge } from 'components/shared/api-health-badge' | ||
| import { AuthBadge } from 'components/shared/auth-badge' | ||
| import { LogOut } from 'lucide-react' | ||
| import Link from 'next/link' | ||
|
|
||
| import { PageTitle } from './page-title' | ||
| import { DashboardSidebar } from './sidebar' | ||
|
|
||
| export default async function Layout({ children }: Readonly<{ children: React.ReactNode }>) { | ||
| return ( | ||
| <SidebarProvider> | ||
| <DashboardSidebar /> | ||
| <div className="flex min-w-0 flex-1"> | ||
| <SidebarInset className="flex min-w-0 flex-1 flex-col"> | ||
| <header className="flex h-14 shrink-0 items-center justify-between gap-3 border-b px-4 md:gap-4 md:px-6"> | ||
| <div className="flex min-h-11 items-center md:hidden"> | ||
| <SidebarTrigger className="size-11 shrink-0" /> | ||
| </div> | ||
| <div className="flex min-w-0 flex-1 items-center"> | ||
| <PageTitle /> | ||
| </div> | ||
| <div className="flex min-h-11 items-center gap-3 md:gap-4"> | ||
| <ApiHealthBadge /> | ||
| <AuthBadge /> | ||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
| className="size-11 sm:size-9" | ||
| aria-label="Sign out" | ||
| asChild | ||
| > | ||
| <Link href="/auth/logout" prefetch={false}> | ||
| <LogOut /> | ||
| </Link> | ||
| </Button> | ||
| </div> | ||
| </header> | ||
| <div className="flex min-h-0 flex-1" style={{ height: 'calc(100dvh - 3.5rem)' }}> | ||
| <main className="min-w-0 w-0 flex-1 overflow-auto p-4 md:p-6">{children}</main> | ||
| <AssistantSidebar /> | ||
| </div> | ||
| </SidebarInset> | ||
| </div> | ||
| <Toaster richColors position="top-right" /> | ||
| </SidebarProvider> | ||
| ) | ||
| export default async function Layout({ | ||
| children, | ||
| }: Readonly<{ children: React.ReactNode }>): Promise<React.JSX.Element> { | ||
| return <DashboardShell>{children}</DashboardShell> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /** Query keys matching @repo/react auth hooks (useUser, useSession). Used for invalidation only. */ | ||
| export const authSessionUserQueryKey = ['auth', 'session', 'user'] as const | ||
| export const authSessionJwtQueryKey = ['auth', 'session', 'jwt'] as const |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.