Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

remove vestigial username (#199)

Bill Yang38a7548a3e37
diff --git a/client/src/app/settings/account/components/AccountInner.tsx b/client/src/app/settings/account/components/AccountInner.tsx
index b028cf4c3..9d1e2e32b 100644
--- a/client/src/app/settings/account/components/AccountInner.tsx
+++ b/client/src/app/settings/account/components/AccountInner.tsx
@@ -11,7 +11,6 @@ import {
CardTitle,
} from "../../../../components/ui/card";
import { Input } from "../../../../components/ui/input";
-import { IS_CLOUD } from "../../../../lib/const";
import { ChangePassword } from "./ChangePassword";
import { DeleteAccount } from "./DeleteAccount";
@@ -20,10 +19,8 @@ export function AccountInner({
}: {
session: ReturnType<typeof authClient.useSession>;
}) {
- const [username, setUsername] = useState(session.data?.user.username ?? "");
const [email, setEmail] = useState(session.data?.user.email ?? "");
const [name, setName] = useState(session.data?.user.name ?? "");
- const [isUpdatingUsername, setIsUpdatingUsername] = useState(false);
const [isUpdatingEmail, setIsUpdatingEmail] = useState(false);
const [isUpdatingName, setIsUpdatingName] = useState(false);
@@ -55,36 +52,6 @@ export function AccountInner({
}
};
- const handleUsernameUpdate = async () => {
- if (!username) {
- toast.error("Username cannot be empty");
- return;
- }
-
- try {
- setIsUpdatingUsername(true);
- const response = await authClient.updateUser({
- username,
- });
-
- if (response.error) {
- throw new Error(response.error.message || "Failed to update username");
- }
-
- toast.success("Username updated successfully");
-
- // Reload the page to refresh the session
- globalThis.location.reload();
- } catch (error) {
- console.error("Error updating username:", error);
- toast.error(
- error instanceof Error ? error.message : "Failed to update username"
- );
- } finally {
- setIsUpdatingUsername(false);
- }
- };
-
const handleEmailUpdate = async () => {
if (!email) {
toast.error("Email cannot be empty");
@@ -127,55 +94,27 @@ export function AccountInner({
<CardTitle className="text-xl">Account</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
- {IS_CLOUD ? (
- <div className="space-y-2">
- <h4 className="text-sm font-medium">Name</h4>
- <p className="text-xs text-neutral-500">
- Update your name displayed across the platform
- </p>
- <div className="flex space-x-2">
- <Input
- id="name"
- value={name}
- onChange={({ target }) => setName(target.value)}
- placeholder="name"
- />
- <Button
- variant="outline"
- onClick={handleNameUpdate}
- disabled={isUpdatingName || name === session.data?.user.name}
- >
- {isUpdatingName ? "Updating..." : "Update"}
- </Button>
- </div>
- </div>
- ) : (
- <div className="space-y-2">
- <h4 className="text-sm font-medium">Username</h4>
- <p className="text-xs text-neutral-500">
- Update your username displayed across the platform
- </p>
- <div className="flex space-x-2">
- <Input
- id="username"
- value={username}
- onChange={({ target }) => setUsername(target.value)}
- placeholder="username"
- />
- <Button
- variant="outline"
- onClick={handleUsernameUpdate}
- disabled={
- isUpdatingUsername ||
- username === session.data?.user.username
- }
- >
- {isUpdatingUsername ? "Updating..." : "Update"}
- </Button>
- </div>
+ <div className="space-y-2">
+ <h4 className="text-sm font-medium">Name</h4>
+ <p className="text-xs text-neutral-500">
+ Update your name displayed across the platform
+ </p>
+ <div className="flex space-x-2">
+ <Input
+ id="name"
+ value={name}
+ onChange={({ target }) => setName(target.value)}
+ placeholder="name"
+ />
+ <Button
+ variant="outline"
+ onClick={handleNameUpdate}
+ disabled={isUpdatingName || name === session.data?.user.name}
+ >
+ {isUpdatingName ? "Updating..." : "Update"}
+ </Button>
</div>
- )}
-
+ </div>
<div className="space-y-2">
<h4 className="text-sm font-medium">Email</h4>
<p className="text-xs text-neutral-500">
diff --git a/client/src/app/settings/organizations/components/AddUser.tsx b/client/src/app/settings/organizations/components/AddUser.tsx
index 87584d303..26a8fd7e1 100644
--- a/client/src/app/settings/organizations/components/AddUser.tsx
+++ b/client/src/app/settings/organizations/components/AddUser.tsx
@@ -18,7 +18,6 @@ import { useState } from "react";
export function AddUser({ refetch }: { refetch: () => void }) {
const [open, setOpen] = useState(false);
- const [username, setUsername] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
@@ -42,8 +41,7 @@ export function AddUser({ refetch }: { refetch: () => void }) {
method: "POST",
body: JSON.stringify({
email,
- username,
- name: username,
+ name: "",
password,
isAdmin,
}),
@@ -67,7 +65,6 @@ export function AddUser({ refetch }: { refetch: () => void }) {
setOpen(isOpen);
setPassword("");
setConfirmPassword("");
- setUsername("");
setEmail("");
setError("");
setIsAdmin(false);
@@ -80,15 +77,6 @@ export function AddUser({ refetch }: { refetch: () => void }) {
<DialogHeader>
<DialogTitle>Add User</DialogTitle>
</DialogHeader>
- <div className="grid w-full items-center gap-1.5">
- <Label htmlFor="name">Username</Label>
- <Input
- id="username"
- value={username}
- onChange={(e) => setUsername(e.target.value)}
- placeholder="Username"
- />
- </div>
<div className="grid w-full items-center gap-1.5">
<Label htmlFor="email">Email</Label>
<Input
@@ -144,9 +132,7 @@ export function AddUser({ refetch }: { refetch: () => void }) {
<Button
type="submit"
onClick={handleSubmit}
- disabled={
- !password || !confirmPassword || !passwordsMatch || !username
- }
+ disabled={!password || !confirmPassword || !passwordsMatch}
>
Create
</Button>
diff --git a/client/src/lib/auth.ts b/client/src/lib/auth.ts
index 5fc00cabd..3a8ae9f70 100644
--- a/client/src/lib/auth.ts
+++ b/client/src/lib/auth.ts
@@ -1,13 +1,9 @@
-import {
- adminClient,
- organizationClient,
- usernameClient,
-} from "better-auth/client/plugins";
+import { adminClient, organizationClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_BACKEND_URL,
- plugins: [usernameClient(), adminClient(), organizationClient()],
+ plugins: [adminClient(), organizationClient()],
fetchOptions: {
credentials: "include",
},