fbele
fbele
CCConvex Community
Created by fbele on 9/5/2024 in #support-community
Make phone provider a valid credentials provider
Currently if a user wants to sign in using account id and password that were created using phone provider the backend returns an error: "Uncaught Error: Provider phone is not a credentials provider", which I understand considering that there is initially no password set. However one (like me :)) could implement a flow where secret (password) is set retrospectively and thus a phone provider could also be used for credentials, but perhaps only when secret field is actually populated. Is something like that to be expected in the future? Thanks.
1 replies
CCConvex Community
Created by fbele on 9/4/2024 in #support-community
afterUserCreatedOrUpdated() not being triggered after user creation or update
I have implemented two providers for phone sign-in using these examples: https://github.com/get-convex/convex-auth-example/blob/f699ad3c4c6d3cdcad6b182b9009004c443e53a5/convex/otp/TwilioOTP.ts https://github.com/get-convex/convex-auth-example/blob/5163bd646c208dfce64b3cd4f05109d3c7dbe6f2/convex/otp/TwilioVerify.ts I want to populate the tokenIdentifier field of the user document for later use. I have extended the authTables's users table to have the tokenIdentifier field available. My auth.ts file looks like this:
import { convexAuth } from "@convex-dev/auth/server";
import { TwilioOTP } from "./otp/TwilioOTP";
import { TwilioVerify } from "./otp/TwilioVerify";

export const { auth, signIn, signOut, store } = convexAuth({
providers: [TwilioOTP, TwilioVerify],

callbacks: {
async afterUserCreatedOrUpdated(ctx, args) {
console.log("profile:", args.profile);
console.log("type:", args.type);
console.log("existing user Id:", args.existingUserId);
const identity = await ctx.auth.getUserIdentity();
await ctx.db.patch(args.userId, { tokenIdentifier: identity?.tokenIdentifier });
},
},
});
import { convexAuth } from "@convex-dev/auth/server";
import { TwilioOTP } from "./otp/TwilioOTP";
import { TwilioVerify } from "./otp/TwilioVerify";

export const { auth, signIn, signOut, store } = convexAuth({
providers: [TwilioOTP, TwilioVerify],

callbacks: {
async afterUserCreatedOrUpdated(ctx, args) {
console.log("profile:", args.profile);
console.log("type:", args.type);
console.log("existing user Id:", args.existingUserId);
const identity = await ctx.auth.getUserIdentity();
await ctx.db.patch(args.userId, { tokenIdentifier: identity?.tokenIdentifier });
},
},
});
The problem is, that is never being called. So I wonder what am I missing?
7 replies
CCConvex Community
Created by fbele on 9/3/2024 in #support-community
Is there a way to use Password + Phone providers for authentication?
I have successfully implemented the Phone provider in my app, but after successful verification of the phone number I would like that a user can define a password for signing in to the app. So it would be a combination of a phone number + password. I know that Password provider can work together with an Email provider (i.e. Resend), which essentially accomplishes what I want to achieve, but it's using an email instead of a phone a channel. Any solution in this regard would be acceptable, so that a user doesn't need to verify an OTP via phone number would be acceptable. Thanks.
3 replies
CCConvex Community
Created by fbele on 9/2/2024 in #support-community
How to update the 'phoneVerified' field in authAccounts table after a successful phone verification?
No description
7 replies
CCConvex Community
Created by fbele on 8/27/2024 in #support-community
Phone provider with Twilio example is returning an error when executing createAccount() method
Hi there, I am trying to implement the Twilio phone provider example as showed here: https://github.com/get-convex/convex-auth-example/blob/main/convex/otp/TwilioOTP.ts The phone number and later the code (OTP) verification is working without an issue, but when it comes to creating an account I am receiving the following error from Convex: ERROR [CONVEX A(auth:signIn)] [Request ID: 8f51f3d87aadd853] Server Error Uncaught Error: Uncaught Error: Uncaught Error: Index authAccounts.providerAndAccountId not found. at handler (../../node_modules/@convex-dev/auth/dist/server/implementation.js:597:54) at async createAccount (../../node_modules/@convex-dev/auth/dist/server/implementation.js:981:14) at async handler (../../convex/otp/TwilioSDK.ts:29:16) at async authorize [as authorize] (../../convex/otp/TwilioVerify.ts:22:8) at async signInImpl (../../node_modules/@convex-dev/auth/dist/server/implementation.js:1149:23) at async handler (../../node_modules/@convex-dev/auth/dist/server/implementation.js:425:20) ERROR [Error: [CONVEX A(auth:signIn)] [Request ID: 8f51f3d87aadd853] Server Error Uncaught Error: Uncaught Error: Uncaught Error: Index authAccounts.providerAndAccountId not found. at handler (../../node_modules/@convex-dev/auth/dist/server/implementation.js:597:54) at async createAccount (../../node_modules/@convex-dev/auth/dist/server/implementation.js:981:14) at async handler (../../convex/otp/TwilioSDK.ts:29:16) at async authorize [as authorize] (../../convex/otp/TwilioVerify.ts:22:8) at async signInImpl (../../node_modules/@convex-dev/auth/dist/server/implementation.js:1149:23) at async handler (../../node_modules/@convex-dev/auth/dist/server/implementation.js:425:20) Called by client] Does anybody have any experience with that and can help me somehow? Thank you.
3 replies