mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-26 13:48:46 +00:00
Merge pull request #3183 from Dokploy/feat/add-last-name-to-profile
feat(user): update user schema to include firstName and lastName fiel…
This commit is contained in:
+4
-4
@@ -16,11 +16,11 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm --filter=@dokploy/server
|
|||||||
|
|
||||||
|
|
||||||
# Deploy only the dokploy app
|
# Deploy only the dokploy app
|
||||||
ARG NEXT_PUBLIC_UMAMI_HOST
|
# ARG NEXT_PUBLIC_UMAMI_HOST
|
||||||
ENV NEXT_PUBLIC_UMAMI_HOST=$NEXT_PUBLIC_UMAMI_HOST
|
# ENV NEXT_PUBLIC_UMAMI_HOST=$NEXT_PUBLIC_UMAMI_HOST
|
||||||
|
|
||||||
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
# ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
||||||
ENV NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
# ENV NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
||||||
|
|
||||||
ARG NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
|
ARG NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
|
||||||
ENV NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=$NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
|
ENV NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=$NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ const baseAdmin: User = {
|
|||||||
enablePaidFeatures: false,
|
enablePaidFeatures: false,
|
||||||
allowImpersonation: false,
|
allowImpersonation: false,
|
||||||
role: "user",
|
role: "user",
|
||||||
|
firstName: "",
|
||||||
|
lastName: "",
|
||||||
metricsConfig: {
|
metricsConfig: {
|
||||||
containers: {
|
containers: {
|
||||||
refreshRate: 20,
|
refreshRate: 20,
|
||||||
@@ -61,7 +63,6 @@ const baseAdmin: User = {
|
|||||||
expirationDate: "",
|
expirationDate: "",
|
||||||
id: "",
|
id: "",
|
||||||
isRegistered: false,
|
isRegistered: false,
|
||||||
name: "",
|
|
||||||
createdAt2: new Date().toISOString(),
|
createdAt2: new Date().toISOString(),
|
||||||
emailVerified: false,
|
emailVerified: false,
|
||||||
image: "",
|
image: "",
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export const ImpersonationBar = () => {
|
|||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
|
||||||
toast.success("Successfully impersonating user", {
|
toast.success("Successfully impersonating user", {
|
||||||
description: `You are now viewing as ${selectedUser.name || selectedUser.email}`,
|
description: `You are now viewing as ${`${selectedUser.name} ${selectedUser.lastName}`.trim() || selectedUser.email}`,
|
||||||
});
|
});
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -195,7 +195,8 @@ export const ImpersonationBar = () => {
|
|||||||
<UserIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
<UserIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||||
<span className="truncate flex flex-col items-start">
|
<span className="truncate flex flex-col items-start">
|
||||||
<span className="text-sm font-medium">
|
<span className="text-sm font-medium">
|
||||||
{selectedUser.name || ""}
|
{`${selectedUser.name} ${selectedUser.lastName}`.trim() ||
|
||||||
|
""}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-muted-foreground">
|
<span className="text-xs text-muted-foreground">
|
||||||
{selectedUser.email}
|
{selectedUser.email}
|
||||||
@@ -242,7 +243,8 @@ export const ImpersonationBar = () => {
|
|||||||
<UserIcon className="h-4 w-4 flex-shrink-0" />
|
<UserIcon className="h-4 w-4 flex-shrink-0" />
|
||||||
<span className="flex flex-col items-start">
|
<span className="flex flex-col items-start">
|
||||||
<span className="text-sm font-medium">
|
<span className="text-sm font-medium">
|
||||||
{user.name || ""}
|
{`${user.name} ${user.lastName}`.trim() ||
|
||||||
|
""}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-muted-foreground">
|
<span className="text-xs text-muted-foreground">
|
||||||
{user.email} • {user.role}
|
{user.email} • {user.role}
|
||||||
@@ -283,10 +285,14 @@ export const ImpersonationBar = () => {
|
|||||||
<AvatarImage
|
<AvatarImage
|
||||||
className="object-cover"
|
className="object-cover"
|
||||||
src={data?.user?.image || ""}
|
src={data?.user?.image || ""}
|
||||||
alt={data?.user?.name || ""}
|
alt={
|
||||||
|
`${data?.user?.firstName} ${data?.user?.lastName}`.trim() ||
|
||||||
|
""
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<AvatarFallback>
|
<AvatarFallback>
|
||||||
{data?.user?.name?.slice(0, 2).toUpperCase() || "U"}
|
{`${data?.user?.firstName?.[0] || ""}${data?.user?.lastName?.[0] || ""}`.toUpperCase() ||
|
||||||
|
"U"}
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
@@ -299,7 +305,8 @@ export const ImpersonationBar = () => {
|
|||||||
Impersonating
|
Impersonating
|
||||||
</Badge>
|
</Badge>
|
||||||
<span className="font-medium">
|
<span className="font-medium">
|
||||||
{data?.user?.name || ""}
|
{`${data?.user?.firstName} ${data?.user?.lastName}`.trim() ||
|
||||||
|
""}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3 text-sm text-muted-foreground flex-wrap">
|
<div className="flex items-center gap-3 text-sm text-muted-foreground flex-wrap">
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ const profileSchema = z.object({
|
|||||||
currentPassword: z.string().nullable(),
|
currentPassword: z.string().nullable(),
|
||||||
image: z.string().optional(),
|
image: z.string().optional(),
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
|
lastName: z.string().optional(),
|
||||||
allowImpersonation: z.boolean().optional().default(false),
|
allowImpersonation: z.boolean().optional().default(false),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,7 +89,8 @@ export const ProfileForm = () => {
|
|||||||
image: data?.user?.image || "",
|
image: data?.user?.image || "",
|
||||||
currentPassword: "",
|
currentPassword: "",
|
||||||
allowImpersonation: data?.user?.allowImpersonation || false,
|
allowImpersonation: data?.user?.allowImpersonation || false,
|
||||||
name: data?.user?.name || "",
|
name: data?.user?.firstName || "",
|
||||||
|
lastName: data?.user?.lastName || "",
|
||||||
},
|
},
|
||||||
resolver: zodResolver(profileSchema),
|
resolver: zodResolver(profileSchema),
|
||||||
});
|
});
|
||||||
@@ -102,7 +104,8 @@ export const ProfileForm = () => {
|
|||||||
image: data?.user?.image || "",
|
image: data?.user?.image || "",
|
||||||
currentPassword: form.getValues("currentPassword") || "",
|
currentPassword: form.getValues("currentPassword") || "",
|
||||||
allowImpersonation: data?.user?.allowImpersonation,
|
allowImpersonation: data?.user?.allowImpersonation,
|
||||||
name: data?.user?.name || "",
|
name: data?.user?.firstName || "",
|
||||||
|
lastName: data?.user?.lastName || "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
keepValues: true,
|
keepValues: true,
|
||||||
@@ -127,6 +130,7 @@ export const ProfileForm = () => {
|
|||||||
currentPassword: values.currentPassword || undefined,
|
currentPassword: values.currentPassword || undefined,
|
||||||
allowImpersonation: values.allowImpersonation,
|
allowImpersonation: values.allowImpersonation,
|
||||||
name: values.name || undefined,
|
name: values.name || undefined,
|
||||||
|
lastName: values.lastName || undefined,
|
||||||
});
|
});
|
||||||
await refetch();
|
await refetch();
|
||||||
toast.success("Profile Updated");
|
toast.success("Profile Updated");
|
||||||
@@ -136,6 +140,7 @@ export const ProfileForm = () => {
|
|||||||
image: values.image,
|
image: values.image,
|
||||||
currentPassword: "",
|
currentPassword: "",
|
||||||
name: values.name || "",
|
name: values.name || "",
|
||||||
|
lastName: values.lastName || "",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error("Error updating the profile");
|
toast.error("Error updating the profile");
|
||||||
@@ -180,9 +185,22 @@ export const ProfileForm = () => {
|
|||||||
name="name"
|
name="name"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Name</FormLabel>
|
<FormLabel>First Name</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="Name" {...field} />
|
<Input placeholder="John" {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="lastName"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Last Name</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="Doe" {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -280,7 +298,7 @@ export const ProfileForm = () => {
|
|||||||
<Avatar className="default-avatar h-12 w-12 rounded-full border hover:p-px hover:border-primary transition-transform">
|
<Avatar className="default-avatar h-12 w-12 rounded-full border hover:p-px hover:border-primary transition-transform">
|
||||||
<AvatarFallback className="rounded-lg">
|
<AvatarFallback className="rounded-lg">
|
||||||
{getFallbackAvatarInitials(
|
{getFallbackAvatarInitials(
|
||||||
data?.user?.name,
|
`${data?.user?.firstName} ${data?.user?.lastName}`.trim(),
|
||||||
)}
|
)}
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ export const UserNav = () => {
|
|||||||
alt={data?.user?.image || ""}
|
alt={data?.user?.image || ""}
|
||||||
/>
|
/>
|
||||||
<AvatarFallback className="rounded-lg">
|
<AvatarFallback className="rounded-lg">
|
||||||
{getFallbackAvatarInitials(data?.user?.name)}
|
{getFallbackAvatarInitials(
|
||||||
|
`${data?.user?.firstName} ${data?.user?.lastName}`.trim(),
|
||||||
|
)}
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<div className="grid flex-1 text-left text-sm leading-tight">
|
<div className="grid flex-1 text-left text-sm leading-tight">
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE "user" RENAME COLUMN "name" TO "firstName";--> statement-breakpoint
|
||||||
|
ALTER TABLE "user" ADD COLUMN "lastName" text DEFAULT '' NOT NULL;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -897,6 +897,13 @@
|
|||||||
"when": 1765095189368,
|
"when": 1765095189368,
|
||||||
"tag": "0127_superb_alice",
|
"tag": "0127_superb_alice",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 128,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1765101709413,
|
||||||
|
"tag": "0128_hard_falcon",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
adminClient,
|
adminClient,
|
||||||
apiKeyClient,
|
apiKeyClient,
|
||||||
|
inferAdditionalFields,
|
||||||
organizationClient,
|
organizationClient,
|
||||||
twoFactorClient,
|
twoFactorClient,
|
||||||
} from "better-auth/client/plugins";
|
} from "better-auth/client/plugins";
|
||||||
@@ -13,5 +14,12 @@ export const authClient = createAuthClient({
|
|||||||
twoFactorClient(),
|
twoFactorClient(),
|
||||||
apiKeyClient(),
|
apiKeyClient(),
|
||||||
adminClient(),
|
adminClient(),
|
||||||
|
inferAdditionalFields({
|
||||||
|
user: {
|
||||||
|
lastName: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import type { NextPage } from "next";
|
|||||||
import type { AppProps } from "next/app";
|
import type { AppProps } from "next/app";
|
||||||
import { Inter } from "next/font/google";
|
import { Inter } from "next/font/google";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import Script from "next/script";
|
|
||||||
import { appWithTranslation } from "next-i18next";
|
import { appWithTranslation } from "next-i18next";
|
||||||
import { ThemeProvider } from "next-themes";
|
import { ThemeProvider } from "next-themes";
|
||||||
import NextTopLoader from "nextjs-toploader";
|
import NextTopLoader from "nextjs-toploader";
|
||||||
@@ -43,14 +42,6 @@ const MyApp = ({
|
|||||||
<Head>
|
<Head>
|
||||||
<title>Dokploy</title>
|
<title>Dokploy</title>
|
||||||
</Head>
|
</Head>
|
||||||
{process.env.NEXT_PUBLIC_UMAMI_HOST &&
|
|
||||||
process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID && (
|
|
||||||
<Script
|
|
||||||
src={process.env.NEXT_PUBLIC_UMAMI_HOST}
|
|
||||||
data-website-id={process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<ThemeProvider
|
<ThemeProvider
|
||||||
attribute="class"
|
attribute="class"
|
||||||
defaultTheme="system"
|
defaultTheme="system"
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ import { api } from "@/utils/api";
|
|||||||
const registerSchema = z
|
const registerSchema = z
|
||||||
.object({
|
.object({
|
||||||
name: z.string().min(1, {
|
name: z.string().min(1, {
|
||||||
message: "Name is required",
|
message: "First name is required",
|
||||||
|
}),
|
||||||
|
lastName: z.string().min(1, {
|
||||||
|
message: "Last name is required",
|
||||||
}),
|
}),
|
||||||
email: z
|
email: z
|
||||||
.string()
|
.string()
|
||||||
@@ -92,6 +95,7 @@ const Invitation = ({
|
|||||||
const form = useForm<Register>({
|
const form = useForm<Register>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: "",
|
name: "",
|
||||||
|
lastName: "",
|
||||||
email: "",
|
email: "",
|
||||||
password: "",
|
password: "",
|
||||||
confirmPassword: "",
|
confirmPassword: "",
|
||||||
@@ -115,6 +119,7 @@ const Invitation = ({
|
|||||||
email: values.email,
|
email: values.email,
|
||||||
password: values.password,
|
password: values.password,
|
||||||
name: values.name,
|
name: values.name,
|
||||||
|
lastName: values.lastName,
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
headers: {
|
headers: {
|
||||||
"x-dokploy-token": token,
|
"x-dokploy-token": token,
|
||||||
@@ -197,12 +202,22 @@ const Invitation = ({
|
|||||||
name="name"
|
name="name"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Name</FormLabel>
|
<FormLabel>First Name</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input placeholder="John" {...field} />
|
||||||
placeholder="Enter your name"
|
</FormControl>
|
||||||
{...field}
|
<FormMessage />
|
||||||
/>
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="lastName"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Last Name</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="Doe" {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ import { authClient } from "@/lib/auth-client";
|
|||||||
const registerSchema = z
|
const registerSchema = z
|
||||||
.object({
|
.object({
|
||||||
name: z.string().min(1, {
|
name: z.string().min(1, {
|
||||||
message: "Name is required",
|
message: "First name is required",
|
||||||
|
}),
|
||||||
|
lastName: z.string().min(1, {
|
||||||
|
message: "Last name is required",
|
||||||
}),
|
}),
|
||||||
email: z
|
email: z
|
||||||
.string()
|
.string()
|
||||||
@@ -79,6 +82,7 @@ const Register = ({ isCloud }: Props) => {
|
|||||||
const form = useForm<Register>({
|
const form = useForm<Register>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: "",
|
name: "",
|
||||||
|
lastName: "",
|
||||||
email: "",
|
email: "",
|
||||||
password: "",
|
password: "",
|
||||||
confirmPassword: "",
|
confirmPassword: "",
|
||||||
@@ -95,6 +99,7 @@ const Register = ({ isCloud }: Props) => {
|
|||||||
email: values.email,
|
email: values.email,
|
||||||
password: values.password,
|
password: values.password,
|
||||||
name: values.name,
|
name: values.name,
|
||||||
|
lastName: values.lastName,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -158,9 +163,22 @@ const Register = ({ isCloud }: Props) => {
|
|||||||
name="name"
|
name="name"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Name</FormLabel>
|
<FormLabel>First Name</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="name" {...field} />
|
<Input placeholder="John" {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="lastName"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Last Name</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="Doe" {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ export const user = pgTable("user", {
|
|||||||
.notNull()
|
.notNull()
|
||||||
.primaryKey()
|
.primaryKey()
|
||||||
.$defaultFn(() => nanoid()),
|
.$defaultFn(() => nanoid()),
|
||||||
name: text("name").notNull().default(""),
|
firstName: text("firstName").notNull().default(""),
|
||||||
|
lastName: text("lastName").notNull().default(""),
|
||||||
isRegistered: boolean("isRegistered").notNull().default(false),
|
isRegistered: boolean("isRegistered").notNull().default(false),
|
||||||
expirationDate: text("expirationDate")
|
expirationDate: text("expirationDate")
|
||||||
.notNull()
|
.notNull()
|
||||||
@@ -332,6 +333,7 @@ export const apiUpdateUser = createSchema.partial().extend({
|
|||||||
password: z.string().optional(),
|
password: z.string().optional(),
|
||||||
currentPassword: z.string().optional(),
|
currentPassword: z.string().optional(),
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
|
lastName: z.string().optional(),
|
||||||
metricsConfig: z
|
metricsConfig: z
|
||||||
.object({
|
.object({
|
||||||
server: z.object({
|
server: z.object({
|
||||||
|
|||||||
@@ -127,16 +127,22 @@ const { handler, api } = betterAuth({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(user);
|
||||||
|
|
||||||
if (IS_CLOUD) {
|
if (IS_CLOUD) {
|
||||||
try {
|
try {
|
||||||
const hutk = getHubSpotUTK(
|
const hutk = getHubSpotUTK(
|
||||||
context?.request?.headers?.get("cookie") || undefined,
|
context?.request?.headers?.get("cookie") || undefined,
|
||||||
);
|
);
|
||||||
|
// Cast to include additional fields
|
||||||
|
const userWithFields = user as typeof user & {
|
||||||
|
lastName?: string;
|
||||||
|
};
|
||||||
const hubspotSuccess = await submitToHubSpot(
|
const hubspotSuccess = await submitToHubSpot(
|
||||||
{
|
{
|
||||||
email: user.email,
|
email: user.email,
|
||||||
firstName: user.name,
|
firstName: user.name || "", // name is mapped to firstName column
|
||||||
lastName: user.name,
|
lastName: userWithFields.lastName || "",
|
||||||
},
|
},
|
||||||
hutk,
|
hutk,
|
||||||
);
|
);
|
||||||
@@ -204,6 +210,9 @@ const { handler, api } = betterAuth({
|
|||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
modelName: "user",
|
modelName: "user",
|
||||||
|
fields: {
|
||||||
|
name: "firstName", // Map better-auth's default 'name' field to 'firstName' column
|
||||||
|
},
|
||||||
additionalFields: {
|
additionalFields: {
|
||||||
role: {
|
role: {
|
||||||
type: "string",
|
type: "string",
|
||||||
@@ -220,6 +229,12 @@ const { handler, api } = betterAuth({
|
|||||||
type: "boolean",
|
type: "boolean",
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
|
lastName: {
|
||||||
|
type: "string",
|
||||||
|
required: false,
|
||||||
|
input: true,
|
||||||
|
defaultValue: "",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
@@ -316,16 +331,11 @@ export const validateRequest = async (request: IncomingMessage) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
// When accessing from DB, use actual column names
|
||||||
id,
|
const userFromDb = apiKeyRecord.user as typeof apiKeyRecord.user & {
|
||||||
name,
|
firstName: string;
|
||||||
email,
|
lastName: string;
|
||||||
emailVerified,
|
};
|
||||||
image,
|
|
||||||
createdAt,
|
|
||||||
updatedAt,
|
|
||||||
twoFactorEnabled,
|
|
||||||
} = apiKeyRecord.user;
|
|
||||||
|
|
||||||
const mockSession = {
|
const mockSession = {
|
||||||
session: {
|
session: {
|
||||||
@@ -333,14 +343,14 @@ export const validateRequest = async (request: IncomingMessage) => {
|
|||||||
activeOrganizationId: organizationId || "",
|
activeOrganizationId: organizationId || "",
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
id,
|
id: userFromDb.id,
|
||||||
name,
|
name: userFromDb.firstName, // Map firstName back to name for better-auth
|
||||||
email,
|
email: userFromDb.email,
|
||||||
emailVerified,
|
emailVerified: userFromDb.emailVerified,
|
||||||
image,
|
image: userFromDb.image,
|
||||||
createdAt,
|
createdAt: userFromDb.createdAt,
|
||||||
updatedAt,
|
updatedAt: userFromDb.updatedAt,
|
||||||
twoFactorEnabled,
|
twoFactorEnabled: userFromDb.twoFactorEnabled,
|
||||||
role: member?.role || "member",
|
role: member?.role || "member",
|
||||||
ownerId: member?.organization.ownerId || apiKeyRecord.user.id,
|
ownerId: member?.organization.ownerId || apiKeyRecord.user.id,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user