view core/tests/Drupal/Nightwatch/Commands/drupalUserIsLoggedIn.js @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
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;
};