Skip to content

Commit 85167e9

Browse files
committed
feat: Removing unusable accounts
1 parent f24abb6 commit 85167e9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

templates/cli/lib/client.js.twig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ const { fetch, FormData, Agent } = require("undici");
44
const JSONbig = require("json-bigint")({ storeAsString: false });
55
const {{spec.title | caseUcfirst}}Exception = require("./exception.js");
66
const { globalConfig } = require("./config.js");
7+
const {log} = require('./parser');
78

89
class Client {
910
CHUNK_SIZE = 5*1024*1024; // 5MB
10-
11+
1112
constructor() {
1213
this.endpoint = '{{spec.endpoint}}';
1314
this.headers = {
@@ -144,6 +145,13 @@ class Client {
144145
} catch (error) {
145146
throw new {{spec.title | caseUcfirst}}Exception(text, response.status, "", text);
146147
}
148+
149+
if(path !== '/account' && json.code === 401 && json.type ==='user_more_factors_required'){
150+
log('Unusable account found, removing...')
151+
const current = globalConfig.getCurrentLogin();
152+
globalConfig.setCurrentLogin('');
153+
globalConfig.removeLogin(current);
154+
}
147155
throw new {{spec.title | caseUcfirst}}Exception(json.message, json.code, json.type, json);
148156
}
149157

0 commit comments

Comments
 (0)