code: function login(user = {
      username: settings.username,
      password: settings.password
  }) {
      return __awaiter(this, void 0, void 0, function* () {
          log_1.logger.info(`[API] Logging in ${user.username}`);
          if (exports.currentLogin !== null) {
              log_1.logger.debug(`[API] Already logged in`);
              if (exports.currentLogin.username === user.username) {
                  return exports.currentLogin.result;
              }
              else {
                  yield logout();
              }
          }
          const result = yield post('login', user, false);
          if (result && result.data && result.data.authToken) {
              exports.currentLogin = {
                  result: result,
                  username: user.username,
                  authToken: result.data.authToken,
                  userId: result.data.userId
              };
              setAuth(exports.currentLogin);
              log_1.logger.info(`[API] Logged in ID ${exports.currentLogin.userId}`);
              return result;
          }
          else {
              throw new Error(`[API] Login failed for ${user.username}`);
          }
      });
  }
docs: Login a user for further API calls
  Result should come back with a token, to authorise following requests.
  Use env default credentials, unless overridden by login arguments.