-
-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enh(#843): Allow signup flow return data when preventLoginFlow is true #903
base: main
Are you sure you want to change the base?
Enh(#843): Allow signup flow return data when preventLoginFlow is true #903
Conversation
commit: |
β¦iamKiNG-Fr/nuxt-auth into enh/843-signup-flow-enhancement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please update your handler to be closer to a demo implementation introduced in #901?
https://github.com/sidebase/nuxt-auth/blob/main/playground-local/server/api/auth/login.post.ts
I think you either can:
- return a "user" object and no access token (we are doing
preventLoginFlow
, right?) innuxt-auth/playground-local/server/api/auth/login.post.ts
Lines 61 to 65 in 5276a97
const user = { username, picture: 'https://github.com/nuxt.png', name: `User ${username}` } - or do both "user" object and access tokens as in
signIn
handler so that reference is usable by others as inspiration and also by tests.
nuxt-auth/playground-local/server/api/auth/login.post.ts
Lines 67 to 90 in 5276a97
const tokenData: JwtPayload = { ...user, scope: ['test', 'user'] } const accessToken = sign(tokenData, SECRET, { expiresIn: ACCESS_TOKEN_TTL }) const refreshToken = sign(tokenData, SECRET, { // 1 day expiresIn: 60 * 60 * 24 }) // Naive implementation - please implement properly yourself! const userTokens: TokensByUser = tokensByUser.get(username) ?? { access: new Map(), refresh: new Map() } userTokens.access.set(accessToken, refreshToken) userTokens.refresh.set(refreshToken, accessToken) tokensByUser.set(username, userTokens) return { token: { accessToken, refreshToken } }
It is fine for me if you don't want to implement option 2, I can take it over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should take over to implement option 2.
I'm not so confident in working with tokens, i would like to learn by seeing your implementation.
I don't mind trying to implement it though if you don't mind, although it might take some trial and error on on my part.
Co-authored-by: Marsel Shayhin <[email protected]>
β¦egResponse Co-authored-by: Marsel Shayhin <[email protected]>
Co-authored-by: Marsel Shayhin <[email protected]>
Co-authored-by: Marsel Shayhin <[email protected]>
π Linked issue
#843
β Type of change
π Description
Added functionality to allow user receive response from server after signup, when preventLoginFlow is true.
π Checklist