@@ -4,10 +4,10 @@ const Client = require("../client");
4
4
const { sdkForConsole, questionGetEndpoint } = require("../sdks");
5
5
const { globalConfig, localConfig } = require("../config");
6
6
const { actionRunner, success, parseBool, commandDescriptions, error, parse, log, drawTable } = require("../parser");
7
+ const ID = require("../id");
7
8
{% if sdk .test != " true" %}
8
9
const { questionsLogin, questionsLogout, questionsListFactors, questionsMfaChallenge } = require("../questions");
9
10
const { accountUpdateMfaChallenge, accountCreateMfaChallenge, accountGet, accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
10
- const ID = require("../id");
11
11
12
12
const DEFAULT_ENDPOINT = 'https://cloud.appwrite.io/v1';
13
13
@@ -259,6 +259,7 @@ const client = new Command("client")
259
259
260
260
if (endpoint !== undefined) {
261
261
try {
262
+ const id = ID.unique();
262
263
let url = new URL(endpoint);
263
264
if (url.protocol !== "http:" && url.protocol !== "https:") {
264
265
throw new Error();
@@ -273,7 +274,8 @@ const client = new Command("client")
273
274
if (!response.version) {
274
275
throw new Error();
275
276
}
276
-
277
+ globalConfig.setCurrentLogin(id);
278
+ globalConfig.addLogin(id, {});
277
279
globalConfig.setEndpoint(endpoint);
278
280
} catch (_) {
279
281
throw new Error("Invalid endpoint or your Appwrite server is not running as expected.");
@@ -293,11 +295,12 @@ const client = new Command("client")
293
295
}
294
296
295
297
if (reset !== undefined) {
296
- globalConfig.setEndpoint("");
297
- globalConfig.setKey("");
298
- globalConfig.setCookie("");
299
- globalConfig.setSelfSigned("");
300
- localConfig.setProject("", "");
298
+ const logins = globalConfig.getLogins();
299
+
300
+ for (let accountId of logins.map(login => login.id)) {
301
+ globalConfig.setCurrentLogin(accountId);
302
+ await singleLogout(accountId);
303
+ }
301
304
}
302
305
303
306
success()
0 commit comments