view core/tests/Drupal/Nightwatch/Commands/drupalUserIsLoggedIn.js @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
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;
};