get-convex / get-convex/convex-auth
question: why can't createAccount method accept a MutationCtx ?
- Dominant language
- TypeScript
- Stars
- 180
- Forks
- 68
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 84
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!
```ts
/*
* src/server/implementation/mutations/createAccountFromCredentials.ts
*/
export const callCreateAccountFromCredentials = async (
ctx: ActionCtx | MutationCtx,
args: Infer,
): Promise => {
return ctx.runMutation("auth:store" as any, {
args: {
type: "createAccountFromCredentials",
...args,
},
});
};
```
```ts
/*
* 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,
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>;
/**
* 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;
user: GenericDoc;
}> {
const actionCtx = ctx as unknown as ActionCtx;
return await callCreateAccountFromCredentials(actionCtx, args);
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Read src/server/implementation/index.ts and src/server/implementation/mutations/createAccountFromCredentials.ts, starting with the createAccount signature and the helper's context usage. Trace the referenced Convex context types and existing callers to determine whether MutationCtx is supported safely. Done means the supported context contract is decided and the relevant API documentation or tests reflect it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100