-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Hello,
Is there any reason why createAccount need an action context ? All it seems it is doing is calling a mutation from that action so a mutation context would be enough no ?
Thank you for your help!
/*
* src/server/implementation/mutations/createAccountFromCredentials.ts
*/
export const callCreateAccountFromCredentials = async (
ctx: ActionCtx | MutationCtx,
args: Infer<typeof createAccountFromCredentialsArgs>,
): Promise<ReturnType> => {
return ctx.runMutation("auth:store" as any, {
args: {
type: "createAccountFromCredentials",
...args,
},
});
};/*
* src/server/implementation/index.ts
*/
/**
* Use this function from a
* [`ConvexCredentials`](https://labs.convex.dev/auth/api_reference/providers/ConvexCredentials)
* provider to create an account and a user with a unique account "id" (OAuth
* provider ID, email address, phone number, username etc.).
*
* @returns user ID if it successfully creates the account
* or throws an error.
*/
export async function createAccount<
DataModel extends GenericDataModel = GenericDataModel,
>(
ctx: GenericActionCtx<DataModel>,
args: {
/**
* The provider ID (like "password"), used to disambiguate accounts.
*
* It is also used to configure account secret hashing via the provider's
* `crypto` option.
*/
provider: string;
account: {
/**
* The unique external ID for the account, for example email address.
*/
id: string;
/**
* The secret credential to store for this account, if given.
*/
secret?: string;
};
/**
* The profile data to store for the user.
* These must fit the `users` table schema.
*/
profile: WithoutSystemFields<DocumentByName<DataModel, "users">>;
/**
* If `true`, the account will be linked to an existing user
* with the same verified email address.
* This is only safe if the returned account's email is verified
* before the user is allowed to sign in with it.
*/
shouldLinkViaEmail?: boolean;
/**
* If `true`, the account will be linked to an existing user
* with the same verified phone number.
* This is only safe if the returned account's phone is verified
* before the user is allowed to sign in with it.
*/
shouldLinkViaPhone?: boolean;
},
): Promise<{
account: GenericDoc<DataModel, "authAccounts">;
user: GenericDoc<DataModel, "users">;
}> {
const actionCtx = ctx as unknown as ActionCtx;
return await callCreateAccountFromCredentials(actionCtx, args);
}Metadata
Metadata
Assignees
Labels
No labels