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

export const { auth, signIn, signOut, store } = convexAuth({
  providers: [
    Google({
      profile(profile) {
        // When in prod: TODO
        // Restrict to @suno.com emails only
        // if (!profile.email?.endsWith("@suno.com")) {
        //   throw new Error("Only @suno.com email addresses are allowed");
        // }
        return {
          id: profile.sub,
          email: profile.email,
          name: profile.name,
          image: profile.picture,
        };
      },
    }),
  ],
});
