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
-
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 thetoken
withtoken.property
and therefreshToken
with therefreshToken.property
. If the responses for the login and refresh endpoints are not the same you can end up withrefreshToken
being populated with whateverrefreshToken.property
retrieves and if the path defined intoken.property
does not conform to your refresh endpoint you get undesired effects such as my example an emptytoken
.It is crossing configurations for
token
andrefreshToken
. It is my understandingtoken
is closely related to theauth.login()
methods whilerefreshToken
is 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 betweentoken
andrefreshToken
requiring 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 thetoken
does get removed/set to empty since my response does not have atokens.access
property found in thetoken
config 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