Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emailVerificationTime and other undocumented surprises #88

Open
laurentpayot opened this issue Sep 30, 2024 · 0 comments
Open

emailVerificationTime and other undocumented surprises #88

laurentpayot opened this issue Sep 30, 2024 · 0 comments

Comments

@laurentpayot
Copy link

laurentpayot commented Sep 30, 2024

Hi, I’m evaluating Convex to migrate a Firebase app.
IMHO, unless your main target are developers, Google OAuth is much more useful to users than the already well documented GitHub OAuth.
The official Google OAuth example does not provide details about the actual Google profile fields we can get. To make it work, I had to go to Google OAuth docs to select the sub field as my ID. I also added the email_verified field that is mandatory for my sign-in process:

auth.js

import { convexAuth } from "@convex-dev/auth/server"
import Google from "@auth/core/providers/google"

export const { auth, signIn, signOut, store } = convexAuth({
  providers: [Google({
    profile(googleProfile, tokens) {
      return {
        id: googleProfile.sub,
        name: googleProfile.name,
        pictureUrl: googleProfile.picture,
        email: googleProfile.email,
        isEmailVerified: googleProfile.email_verified,
      }
    }
  })]
})

I was surprised to see that an emailVerificationTime was automagically created in my users table. I had to add it to my schema:

schema.ts

import { defineSchema, defineTable } from "convex/server"
import { authTables } from "@convex-dev/auth/server"
import { v } from "convex/values"

const schema = defineSchema({
  ...authTables,
  users: defineTable({
    name: v.optional(v.string()),
    pictureUrl: v.optional(v.string()),
    email: v.string(),
    isEmailVerified: v.boolean(),
    // added by Convex
    emailVerificationTime: v.optional(v.number()),
  }).index("email", ["email"]),
})

export default schema

This field is undocumented but it looks likes it stores the time of the first successful authentification. Am I right? If so, the choice of the name emailVerificationTime is maybe not the best because it can be confusing along with an email_verified field set to false. Anyway, could you add a bit of documentation about that mysterious emailVerificationTime? Thanks for your nice product!

Somewhat related to #83.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant