[1.4.1] ctx.internalAdapter.updatePassword doesn't work since i upgrade to last version

I don't undestand why ctx.internalAdapter.updatePassword doesn't work now. Here is my code:
"use server";

import { authUserActionClient } from "../safe-action";
import { completeUserSchema } from "@/lib/zod/schema/users";
import { auth } from "@/lib/better-auth/auth";
import { prisma } from "@/lib/prisma";

export const updateUserAccountAction = authUserActionClient
.schema(completeUserSchema)
.action(async ({ ctx, parsedInput }) => {
const { password, name } = parsedInput;
const id = ctx.user.id;

const authCtx = await auth.$context;
const hash = await authCtx.password.hash(password);

try {
await authCtx.internalAdapter.updatePassword(id, hash);
} catch (error) {
console.error(error);
throw new Error("Failed to update password");
}

await prisma.user.update({
where: { id },
data: {
name,
},
});

return { ok: true };
});
"use server";

import { authUserActionClient } from "../safe-action";
import { completeUserSchema } from "@/lib/zod/schema/users";
import { auth } from "@/lib/better-auth/auth";
import { prisma } from "@/lib/prisma";

export const updateUserAccountAction = authUserActionClient
.schema(completeUserSchema)
.action(async ({ ctx, parsedInput }) => {
const { password, name } = parsedInput;
const id = ctx.user.id;

const authCtx = await auth.$context;
const hash = await authCtx.password.hash(password);

try {
await authCtx.internalAdapter.updatePassword(id, hash);
} catch (error) {
console.error(error);
throw new Error("Failed to update password");
}

await prisma.user.update({
where: { id },
data: {
name,
},
});

return { ok: true };
});
And my error: Error: No auth context found. Please make sure you are calling this function within a runWithEndpointContext callback. Can you help me please. Thank you
1 Reply
Ping
Ping14h ago
cc @Alex Yang

Did you find this page helpful?