darc
BABetter Auth
•Created by darc on 3/20/2025 in #help
Trigger Session update ( to update user data)
oh my bad
i was caching the session it works now when removing the caching setting
session: {
cookieCache: {
enabled: true,
maxAge: 5 * 60, // Cache duration in seconds
},
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg", // or "mysql", "sqlite"
schema: schema,
}),
session: {
cookieCache: {
enabled: true,
maxAge: 5 * 60, // Cache duration in seconds
},
},
user: {
additionalFields: {
role: {
type: "string",
required: true,
},
username: {
type: "string",
required: true,
},
streaks: {
type: "number",
required: true,
},
credits: {
type: "number",
required: true,
},
},
},
/* account: {
accountLinking: {
enabled: true,
trustedProviders: ["google"],
},
}, */
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
plugins: [jwt()],
});
5 replies
BABetter Auth
•Created by darc on 3/20/2025 in #help
Trigger Session update ( to update user data)
this is my server action for handling the onboarding
5 replies
BABetter Auth
•Created by darc on 3/20/2025 in #help
Trigger Session update ( to update user data)
export async function handleOnBoarding(
unsafeData: z.infer<typeof onBoardingSchema>
) {
const { success, data } = onBoardingSchema.safeParse(unsafeData);
if (!success) {
return { error: true, message: "Invalid input data" };
}
const session = await getSessionUser();
if (!session) {
return { error: true, message: "User session not found" };
}
const user = session.user;
await updateUserOnboarding({
userId: user.id,
username: data.username,
TOS: data.TOS,
});
console.log("User onboarding completed:", data);
redirect("/dashboard");
}
5 replies
BABetter Auth
•Created by darc on 3/19/2025 in #help
On-boarding step after social login
thanks It worked perfectly
5 replies