-
Notifications
You must be signed in to change notification settings - Fork 0
fix(auth): resolve stale auth data issue #147
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
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,7 +27,6 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import UserAvatar from "../profile/user-avatar"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { authClient } from "@/lib/auth-client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Skeleton } from "@/components/ui"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useRouter } from "next/navigation"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { toast } from "sonner"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function NavUser() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -114,17 +113,14 @@ export function NavUser() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function LogoutItem() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const router = useRouter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async function handleLogout() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { error } = await authClient.signOut(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast.error(error.message || "Something went wrong"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast.success("Logged out successfully"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| router.push("/"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| router.refresh(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| window.location.href = "/"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
115
to
125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Toast may not be visible before the hard redirect.
Option: small delay before redirect } else {
toast.success("Logged out successfully");
- window.location.href = "/";
+ setTimeout(() => {
+ window.location.href = "/";
+ }, 300);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,6 @@ import UserAvatar from "./user-avatar"; | |
| import Link from "next/link"; | ||
| import { toast } from "sonner"; | ||
| import { authClient } from "@/lib/auth-client"; | ||
| import { useRouter } from "next/navigation"; | ||
| import { useIsMobile } from "@/hooks/use-mobile"; | ||
| import { cn } from "@/lib/utils"; | ||
|
|
||
|
|
@@ -125,17 +124,15 @@ function PendingQuestionsItem() { | |
| } | ||
|
|
||
| function LogoutItem() { | ||
| const router = useRouter(); | ||
|
|
||
| async function handleLogout() { | ||
| const { error } = await authClient.signOut(); | ||
|
|
||
| if (error) { | ||
| toast.error(error.message || "Something went wrong"); | ||
| } else { | ||
| toast.success("Logged out successfully"); | ||
| router.push("/"); | ||
| router.refresh(); | ||
| // Hard redirect to fully clear Router Cache + stale auth state | ||
| window.location.href = "/"; | ||
| } | ||
| } | ||
|
Comment on lines
126
to
137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same toast-before-redirect issue as in The same toast visibility concern applies here. Additionally, both 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
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.
Add a trailing newline at end of file.
Static analysis (dotenv-linter) flags the missing blank line at EOF. Most tools and POSIX conventions expect a trailing newline.
NEXT_PUBLIC_S3_BUCKET= +📝 Committable suggestion
🧰 Tools
🪛 dotenv-linter (4.0.0)
[warning] 38-38: [EndingBlankLine] No blank line at the end of the file
(EndingBlankLine)
🤖 Prompt for AI Agents