-
Notifications
You must be signed in to change notification settings - Fork 51
feat(auth): migrate from Clerk to Better Auth #543
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "use client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useClerk } from "@clerk/nextjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { authClient } from "@superset/auth/client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { RouterOutputs } from "@superset/trpc"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Avatar, AvatarFallback, AvatarImage } from "@superset/ui/avatar"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -25,7 +25,6 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| LuLogOut, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| LuSettings, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "react-icons/lu"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { env } from "@/env"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface NavUserProps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -34,13 +33,22 @@ export interface NavUserProps { | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function NavUser({ user }: NavUserProps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { isMobile } = useSidebar(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { signOut } = useClerk(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| const userInitials = user.name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .split(" ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .map((name) => name[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .join(""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleSignOut = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| await authClient.signOut({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetchOptions: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSuccess: () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| window.location.href = env.NEXT_PUBLIC_WEB_URL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+50
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. Add error handling to the sign-out flow. The 🔎 Proposed fix const handleSignOut = async () => {
- await authClient.signOut({
- fetchOptions: {
- onSuccess: () => {
- window.location.href = env.NEXT_PUBLIC_WEB_URL;
+ try {
+ await authClient.signOut({
+ fetchOptions: {
+ onSuccess: () => {
+ window.location.href = env.NEXT_PUBLIC_WEB_URL;
+ },
+ onError: (ctx) => {
+ console.error("[NavUser/signOut] Sign-out failed:", ctx.error);
+ },
},
- },
- });
+ });
+ } catch (error) {
+ console.error("[NavUser/signOut] Unexpected error:", error);
+ }
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <SidebarMenu> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <SidebarMenuItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -51,10 +59,7 @@ export function NavUser({ user }: NavUserProps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Avatar className="h-8 w-8 rounded-lg"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AvatarImage | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| src={user.avatarUrl ?? undefined} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| alt={user.name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AvatarImage src={user.image ?? undefined} alt={user.name} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AvatarFallback className="rounded-lg"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| {userInitials} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </AvatarFallback> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -75,10 +80,7 @@ export function NavUser({ user }: NavUserProps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| <DropdownMenuLabel className="p-0 font-normal"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Avatar className="h-8 w-8 rounded-lg"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AvatarImage | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| src={user.avatarUrl ?? undefined} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| alt={user.name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AvatarImage src={user.image ?? undefined} alt={user.name} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AvatarFallback className="rounded-lg"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| {userInitials} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </AvatarFallback> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -105,9 +107,7 @@ export function NavUser({ user }: NavUserProps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| </DropdownMenuItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DropdownMenuGroup> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DropdownMenuSeparator /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DropdownMenuItem | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => signOut({ redirectUrl: env.NEXT_PUBLIC_WEB_URL })} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DropdownMenuItem onClick={handleSignOut}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <LuLogOut /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log out | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DropdownMenuItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Critical: Removal contradicts reviewer's explicit feedback on soft-delete functionality.
The removal of the "Deleted Users" navigation item and
LuUserXicon directly conflicts with the reviewer's documented expectations in the PR objectives. The reviewer explicitly requested:Removing this navigation eliminates the UI entry point for:
The reviewer noted that hard deletion is irreversible and prevents user recovery for compliance or user-requested restores. This change should be reverted or the soft-delete functionality should be reimplemented before merging.
</review_comment_end>
Also applies to: 37-48
🤖 Prompt for AI Agents