Config for refreshToken pulls setting from token property #1608
rukamir
started this conversation in
Ideas & Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Version
module: 5.0.0-1608568767.2fe2217
nuxt: 2.14.12
Issue Description
When you call
auth.refreshTokens()it is looking for both types of tokens. It will populate thetokenwithtoken.propertyand therefreshTokenwith therefreshToken.property. If the responses for the login and refresh endpoints are not the same you can end up withrefreshTokenbeing populated with whateverrefreshToken.propertyretrieves and if the path defined intoken.propertydoes not conform to your refresh endpoint you get undesired effects such as my example an emptytoken.It is crossing configurations for
tokenandrefreshToken. It is my understandingtokenis closely related to theauth.login()methods whilerefreshTokenis closely related toauth.refreshTokens()method. To make this more explicit it might be beneficial to allow both of these settings to be configured independently.Nuxt configuration
mode:
nuxt.config.js
/api/v1/auth/login example response
/api/v1/auth/refresh example response
auth-module/src/schemes/refresh.ts
auth-module/src/schemes/refresh.ts
Lines 214 to 226 in 2fe2217
On these two lines
auth-module/src/schemes/refresh.ts
Line 219 in 2fe2217
auth-module/src/schemes/refresh.ts
Line 224 in 2fe2217
Proposal
As mentioned above,
auth.refreshTokens()gets confusing as it is implicitly crossing configurations betweentokenandrefreshTokenrequiring both endpoint responses to be the same. To use my response as an example and if I did return both token types for a refresh endpoint as the code looks like it attempts to achieve:This allows a refresh endpoint to be unique if desired and is explicit about what the settings are doing.
Verification
I have verified that when I call
auth.refreshTokens()the default cookie[auth._token.local] holding thetokendoes get removed/set to empty since my response does not have atokens.accessproperty found in thetokenconfig block innuxt.config.js.Work Around
Have your Refresh and Login endpoints return the same body structure. If you do not want to issue a new refresh token, you can just return the refresh token sent along with the newly generated token.
/api/v1/auth/login & /api/v1/auth/login example response
Beta Was this translation helpful? Give feedback.
All reactions