view core/tests/Drupal/Nightwatch/Commands/drupalUserIsLoggedIn.js @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents
children
line wrap: on
line source
/**
 * Checks if a user is logged in.
 *
 * @param {function} callback
 *   A callback which will be called, when the login status has been checked.
 * @return {object}
 *   The drupalUserIsLoggedIn command.
 */
exports.command = function drupalUserIsLoggedIn(callback) {
  if (typeof callback === 'function') {
    this.getCookies(cookies => {
      const sessionExists = cookies.value.some(cookie =>
        cookie.name.match(/^SESS/),
      );

      callback.call(this, sessionExists);
    });
  }

  return this;
};