fix: custom account-fields (#190)

* fix: custom account-fields

* fix: type
This commit is contained in:
Bereket Engida
2024-10-16 09:05:02 +03:00
committed by GitHub
parent fe239cec57
commit 351a3c883f
3 changed files with 33 additions and 10 deletions

View 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);
});
});

View File

@@ -134,7 +134,6 @@ export const signUpEmail = <O extends BetterAuthOptions>() =>
{
user: createdUser,
session,
error: null,
},
{
body: body.callbackURL

View File

@@ -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,
{