-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refresh tokens #7
Conversation
src/client/AutherClient.js
Outdated
this.logger.log(`Access token has been refreshed successfully at ${currentTime}`) | ||
this.logger.log(`Refresh token has been refreshed successfully at ${currentTime}`) |
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.
в силу того, что токены обновляются всегда парой, лично я не вижу смысла выводить в консоль две строчки в таком виде и предлагаю просто писать, что токены обновлены
src/client/AutherClient.js
Outdated
this.#refreshTokensByTimer({ fetchTokens, saveTokens }) | ||
} | ||
|
||
#refreshTokensByTimer = ({ fetchTokens, saveTokens }) => { |
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.
в целом, на самом деле, этот метод токены не рефрешит, а лишь ставит макрозадачу на обновление, может так и назвать, что-то типа scheduleRefreshTokens ?
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.
ну или даже scheduleTokensRefreshing, но это немного не так явно согласуется с оригинальным названием
src/client/AutherClient.js
Outdated
authentication = async ({ fetchTokens, saveTokens }) => { | ||
const { accessToken } = fetchTokens() | ||
try { | ||
verify(accessToken) | ||
} | ||
catch (err) { | ||
await this.#refresh({ fetchTokens, saveTokens, immediate: true }) | ||
return | ||
} | ||
|
||
this.#refresh({ fetchTokens, saveTokens, immediate: false }) | ||
} |
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.
ну лично мне кажется, логика несколько переусложенена с этим immediate, не? можно же просто сделать
authentication = async ({ fetchTokens, saveTokens }) => { | |
const { accessToken } = fetchTokens() | |
try { | |
verify(accessToken) | |
} | |
catch (err) { | |
await this.#refresh({ fetchTokens, saveTokens, immediate: true }) | |
return | |
} | |
this.#refresh({ fetchTokens, saveTokens, immediate: false }) | |
} | |
authentication = async ({ fetchTokens, saveTokens }) => { | |
const { accessToken } = fetchTokens() | |
try { | |
verify(accessToken) | |
} | |
catch (err) { | |
await this.#refresh({ fetchTokens, saveTokens }) | |
return | |
} | |
this.#scheduleRefreshTokens({ fetchTokens, saveTokens }) | |
} |
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.
лично на мой вкус так более явно прослеживается намерение, чем прыгать по методам с иммедиейтом
src/client/AutherClient.js
Outdated
} | ||
catch (err) { | ||
await this.#refresh({ fetchTokens, saveTokens, immediate: true }) | ||
return |
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.
а почему при обычном рефреше делается ретюрн? оно же не поставит задачу на обновление, или там хитрее как-то работает, а я не уследил?
No description provided.