api-client/turnstile: don't retry making session if it's not needed
This commit is contained in:
parent
5d7cd861f3
commit
95f0fbdb5e
1 changed files with 10 additions and 7 deletions
|
@ -26,17 +26,20 @@ export class TurnstileCobaltAPI extends CobaltAPI {
|
|||
}
|
||||
|
||||
async request(data: CobaltRequest) {
|
||||
const sessionOrError = await this.#session.getSession();
|
||||
const headers: Record<string, string> = {};
|
||||
|
||||
if ("error" in sessionOrError) {
|
||||
if (sessionOrError.error.code !== CobaltAuthError.NotConfigured) {
|
||||
return sessionOrError;
|
||||
if (this.#instanceHasTurnstile) {
|
||||
const sessionOrError = await this.#session.getSession();
|
||||
|
||||
if ("error" in sessionOrError) {
|
||||
if (sessionOrError.error.code !== CobaltAuthError.NotConfigured) {
|
||||
return sessionOrError;
|
||||
} else {
|
||||
this.#instanceHasTurnstile = false;
|
||||
}
|
||||
} else {
|
||||
this.#instanceHasTurnstile = false;
|
||||
headers['Authorization'] = `Bearer ${sessionOrError.token}`;
|
||||
}
|
||||
} else {
|
||||
headers['Authorization'] = `Bearer ${sessionOrError.token}`;
|
||||
}
|
||||
|
||||
return super.request(data, headers);
|
||||
|
|
Loading…
Reference in a new issue