mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-26 08:56:40 -05:00
fix: custom account-fields (#190)
* fix: custom account-fields * fix: type
This commit is contained in:
32
packages/better-auth/src/api/routes/sign-up.test.ts
Normal file
32
packages/better-auth/src/api/routes/sign-up.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, expect } from "vitest";
|
||||
import { getTestInstance } from "../../test-utils/test-instance";
|
||||
|
||||
describe("sign-up with custom fields", async (it) => {
|
||||
it("should work with custom fields on account table", async () => {
|
||||
const { auth, db } = await getTestInstance(
|
||||
{
|
||||
account: {
|
||||
fields: {
|
||||
providerId: "provider_id",
|
||||
accountId: "account_id",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
disableTestUser: true,
|
||||
},
|
||||
);
|
||||
const res = await auth.api.signUpEmail({
|
||||
body: {
|
||||
email: "email@test.com",
|
||||
password: "password",
|
||||
name: "name",
|
||||
},
|
||||
});
|
||||
expect(res.user).toBeDefined();
|
||||
const accounts = await db.findMany({
|
||||
model: "account",
|
||||
});
|
||||
expect(accounts).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -134,7 +134,6 @@ export const signUpEmail = <O extends BetterAuthOptions>() =>
|
||||
{
|
||||
user: createdUser,
|
||||
session,
|
||||
error: null,
|
||||
},
|
||||
{
|
||||
body: body.callbackURL
|
||||
|
||||
@@ -122,15 +122,7 @@ export const username = () => {
|
||||
...ctx,
|
||||
_flag: "json",
|
||||
});
|
||||
if (res.error) {
|
||||
return ctx.json(null, {
|
||||
status: 400,
|
||||
body: {
|
||||
message: res.error,
|
||||
status: 400,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const updated = await ctx.context.internalAdapter.updateUserByEmail(
|
||||
res.user?.email,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user