nuxt-auth icon indicating copy to clipboard operation
nuxt-auth copied to clipboard

Need to send the lang in the params as dynamic from the i18n package

Open hadelnasr opened this issue 1 year ago • 3 comments

Environment

Nuxt project info: 10:54:41 AM



Reproduction

i need to access the application localization state either from context or from cookie to be able to inject it in the params.lang value instead of sending it statically this way

Describe the bug

Here is my logic i'm adding in the [...].ts file

export default NuxtAuthHandler({ secret: runtimeConfig.authSecret, providers: [ { id: "SSO", name: "SSO", type: "oauth", wellKnown: runtimeConfig.ssoWellKnown, idToken: true, // Use ID token in the flow authorization: { url: runtimeConfig.ssoAuthorizationUrl, params: { scope: "openid profile offline_access nafeza_api", resource: "urn:egwin:api", lang: 'ar', }, }, clientId: runtimeConfig.nafezaClientId, clientSecret: runtimeConfig.nafezaClientSecret, debug: process.env.NODE_ENV === "development", profile(profile: any, account: any) { return { id: profile.sub, name: profile.profile.name, email: profile.profile.email }; }, }, ], debug: true, session: { maxAge: 30 * 24 * 60 * 60, // 30 days updateAge: 24 * 60 * 60, // 24 hours }, jwt: { secret: process.env.NUXT_API_SECRET, maxAge: 60 * 60, // 1 hour token expiry }, callbacks: { // @ts-ignore async jwt({ token, account }) { if (token && account?.id_token) { token.idToken = account.id_token; } if (token && account?.access_token) { token.accessToken = account.access_token; } return token; }, // @ts-ignore async session({ session, token }) { session.user.idToken = token.idToken; session.user.accessToken = token.accessToken; return session; }, }, // your authentication configuration here! events: { async signIn(message: object) { console.log("signIn event - message:", message); }, async signOut(message: object) { console.log("signOut event - message:", message); }, async createUser(message: object) { console.log("createUser event - message:", message); }, async updateUser(message: object) { console.log("updateUser event - message:", message); }, async linkAccount(message: object) { console.log("linkAccount event - message:", message); }, async session(message: object) { console.log("session event - message:", message); }, }, pages: { signIn: '/login' } })

i need to access the application localization state either from context or from cookie to be able to inject it in the params.lang value instead of sending it statically this way

Additional context

No response

Logs

No response

hadelnasr avatar Nov 13 '24 08:11 hadelnasr

@drusellers @zerekw @DavidDeSloovere @ayalon any update guys?

hadelnasr avatar Nov 13 '24 12:11 hadelnasr

it's fixed by adding the lang as a parameter in the auth signIn function

await signIn("PROVIDER", {}, { lang: 'en' });

hadelnasr avatar Nov 17 '24 09:11 hadelnasr

I just wrote my own and bailed on this package.

drusellers avatar Nov 18 '24 21:11 drusellers