if (ctx.path.startsWith("/callback/")) { //Here just use a /callback/ to catch all OAuth routes
const newSession = ctx.context.newSession ?? ctx.context.session;
if (newSession) {
try {
const locale = ctx.getCookie("NEXT_LOCALE") || "en";
await userRepository.updateUserLocale(newSession.user.id, locale);
console.log(
`OAuth user ${newSession.user.id} created with locale: ${locale}`
);
} catch (error) {
console.error("Failed to set OAuth user locale:", error);
}
}
}
if (ctx.path.startsWith("/callback/")) { //Here just use a /callback/ to catch all OAuth routes
const newSession = ctx.context.newSession ?? ctx.context.session;
if (newSession) {
try {
const locale = ctx.getCookie("NEXT_LOCALE") || "en";
await userRepository.updateUserLocale(newSession.user.id, locale);
console.log(
`OAuth user ${newSession.user.id} created with locale: ${locale}`
);
} catch (error) {
console.error("Failed to set OAuth user locale:", error);
}
}
}