agun40
CCConvex Community
•Created by shea on 9/1/2024 in #support-community
IdTokenExpired on using convexAuthNextjsToken in production
okay let go there sir
95 replies
CCConvex Community
•Created by shea on 9/1/2024 in #support-community
IdTokenExpired on using convexAuthNextjsToken in production
hi, can you help me with mine
95 replies
CCConvex Community
•Created by shea on 9/1/2024 in #support-community
IdTokenExpired on using convexAuthNextjsToken in production
this is my mutation function
export const signUpAdmin = mutation({
args: {
email: v.string(),
name: v.string(),
password: v.string(),
},
handler: async ({ db }, { email, name, password }) => {
// Hash the password
const hashedPassword = await bcrypt.hash(password, 10);
// Insert the admin user into the admin table
await db.insert("admin", {
email,
name,
password: hashedPassword,
tokenIdentifier: "", // Initialize with an empty string or generate a token
} as { email: string; name: string; password: string; tokenIdentifier: string });
},
});
95 replies
CCConvex Community
•Created by shea on 9/1/2024 in #support-community
IdTokenExpired on using convexAuthNextjsToken in production
This is my schema
// convex/schema.ts
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";
import { authTables } from "@convex-dev/auth/server";
export default defineSchema({
...authTables,
users: defineTable({
name: v.optional(v.string()),
image: v.optional(v.string()),
email: v.optional(v.string()),
emailVerificationTime: v.optional(v.number()),
phone: v.optional(v.string()),
phoneVerificationTime: v.optional(v.number()),
isAnonymous: v.optional(v.boolean()),
// other "users" fields...
role: v.optional(v.string()),
}).index("email", ["email"]),
admin: defineTable({
email: v.string(), // Add the email field
name: v.string(),
tokenIdentifier: v.string(),
}).index("by_token", ["tokenIdentifier"]),
students: defineTable({
email: v.string(),
role: v.string(),
password: v.string(),
}).index("email", ["email"]),
teachers: defineTable({
email: v.string(),
role: v.string(),
password: v.string(),
}).index("email", ["email"]),
});
95 replies
CCConvex Community
•Created by shea on 9/1/2024 in #support-community
IdTokenExpired on using convexAuthNextjsToken in production
how can i solve the issues
95 replies
CCConvex Community
•Created by shea on 9/1/2024 in #support-community
IdTokenExpired on using convexAuthNextjsToken in production
import { query } from "./_generated/server";
import { v } from "convex/values";
import { User } from "./type/userType";
export const getUser = query({
args: {
email: v.string(),
},
handler: async ({ db }, { email }) => {
const user = await db.query("users").filter(q => q.eq("email", email)).first();
return user || null;
},
});
95 replies
CCConvex Community
•Created by shea on 9/1/2024 in #support-community
IdTokenExpired on using convexAuthNextjsToken in production
const { signIn } = useAuthActions();
const [flow, setFlow] = useState<"signIn" | "signUp">("signIn");
const { toast } = useToast();
const [submitting, setSubmitting] = useState(false);
const storeAdmin = useMutation(api.admin.storeUser);
const router = useRouter();
const renderForm = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
setSubmitting(true);
const formData = new FormData(event.currentTarget);
const email = formData.get("email") as string;
const password = formData.get("password") as string;
console.log("Form Data:", { email, password });
try {
if (flow === "signUp") {
// Sign in the user first to ensure authentication
await signIn("password", formData);
// Now call the storeAdmin mutation
await storeAdmin({ user: { email, name: "Admin", password, role: "admin" } });
} else {
await signIn("password", formData);
}
router.push('/admin/dashboard');
i am getting undefined and null
95 replies