Esempio n. 1
0
module.exports.findByEmail = function(email, callback) {
  var query;

  if (util.isArray(email)) {
    query = {
      $or: email.map(function(e) {
        return {
          accounts: {
            $elemMatch: {
              emails: trim(e).toLowerCase()
            }
          }
        };
      })
    };
  } else {
    query = {
      accounts: {
        $elemMatch: {
          emails: trim(email).toLowerCase()
        }
      }
    };
  }

  User.findOne(query, callback);
};
Esempio n. 2
0
File: index.js Progetto: auth0/lock
function assertMaybeString(opts, name) {
  const valid =
    opts[name] === undefined || (typeof opts[name] === 'string' && trim(opts[name]).length > 0);
  if (!valid)
    l.warn(opts, `The \`${name}\` option will be ignored, because it is not a non-empty string.`);
  return valid;
}
Esempio n. 3
0
	    };module.exports = function (r) {
	      if (!r) return {};var e = {};return (forEach(trim(r).split("\n"), function (r) {
	        var t = r.indexOf(":"),
	            i = trim(r.slice(0, t)).toLowerCase(),
	            o = trim(r.slice(t + 1));"undefined" == typeof e[i] ? e[i] = o : isArray(e[i]) ? e[i].push(o) : e[i] = [e[i], o];
	      }), e);
	    };
Esempio n. 4
0
    function parseComment(node, output) {
        var m;
        if (node.type === 'Line') {
            m = AT_REQUIRE_RX.exec(node.value);
            if (m && m[1]) {
                if (DOT_JS_RX.test(m[1])) {
                    // @require path/to/file.js
                    output.dependencies.push(path.resolve(_currentDirPath, trim(m[1])));
                } else {
                    // @require Class.Name
                    addClassNames(output.dependencies, m[1]);
                }
            }

            while (m = DEFINE_RX.exec(node.value)) {
                if (m[1]) {
                    addClassNames(output.classNames, m[1]);
                }
            }
        } else if (node.type === 'Block') {
            while (m = ALTERNATE_CLASS_NAME_RX.exec(node.value)) {
                if (m[1]) {
                    addClassNames(output.classNames, m[1]);
                }
            }
        }
    }
module.exports = function (headers) {
  if (!headers)
    return {}

  var result = {}

  forEach(
      trim(headers).split('\n')
    , function (row) {
        var index = row.indexOf(':')
          , key = trim(row.slice(0, index)).toLowerCase()
          , value = trim(row.slice(index + 1))

        if (typeof(result[key]) === 'undefined') {
          result[key] = value
        } else if (isArray(result[key])) {
          result[key].push(value)
        } else {
          result[key] = [ result[key], value ]
        }
      }
  )

  return result
}
Esempio n. 6
0
RedactPopover.prototype.onselect = function(e){
  if ('' == trim(selected())) return;
  var pos = this.position();
  this.tip.position(pos.at);
  this.classes.add('redact-popover');
  this.tip.show(pos.x, pos.y);
};
Esempio n. 7
0
Auth0.prototype.loginWithResourceOwner = function (options, callback) {
  var self = this;
  var query = xtend(
    this._getMode(),
    options,
    {
      client_id:    this._clientID,
      username:     trim(options.username || options.email || ''),
      grant_type:   'password'
    });

  this._addOfflineMode(query);

  var endpoint = '/oauth/ro';

  function enrichGetProfile(resp, callback) {
    self.getProfile(resp.id_token, function (err, profile) {
      callback(err, profile, resp.id_token, resp.access_token, resp.state, resp.refresh_token);
    });
  }

  if (this._useJSONP) {
    return jsonp('https://' + this._domain + endpoint + '?' + qs.stringify(query), jsonpOpts, function (err, resp) {
      if (err) {
        return callback(err);
      }
      if('error' in resp) {
        var error = new LoginError(resp.status, resp.error);
        return callback(error);
      }
      enrichGetProfile(resp, callback);
    });
  }

  reqwest({
    url:     'https://' + this._domain + endpoint,
    method:  'post',
    type:    'json',
    data:    query,
    crossOrigin: true,
    success: function (resp) {
      enrichGetProfile(resp, callback);
    }
  }).fail(function (err) {
    var er = err;
    if (!er.status || er.status === 0) { //ie10 trick
      er = {};
      er.status = 401;
      er.responseText = {
        code: 'invalid_user_password'
      };
    }
    else {
      er.responseText = err;
    }
    var error = new LoginError(er.status, er.responseText);
    callback(error);
  });
};
Esempio n. 8
0
ResetPanel.prototype.valid = function () {
  var ok = true;
  var email_input = this.query('input[name=email]');
  var email = trim(email_input.val());
  var email_empty = empty.test(email);
  var email_parsed = email_parser.exec(email.toLowerCase());
  var validate_username = this.options._isUsernameRequired();
  var username_parsed = regex.username_parser.exec(email_input.val().toLowerCase());
  var password_input = this.query('input[name=password]');
  var password = password_input.val();
  var password_empty = empty.test(password);
  var repeat_password_input = this.query('input[name=repeat_password]');
  var repeat_password = repeat_password_input.val();
  var repeat_password_empty = empty.test(repeat_password);
  var widget = this.widget;

  // asume valid by default
  // and reset errors
  widget._showError();
  widget._focusError();

  if (email_empty) {
    var error_message = validate_username ? 'username empty' : 'email empty';
    widget.emit('reset error', new ValidationError(error_message));
    widget._focusError(email_input);
    ok = false;
  }

  if (!email_parsed && !email_empty) {
    ok = false || (validate_username && username_parsed);

    if (!ok) {
      var invalid_error = validate_username ? 'username invalid' : 'email invalid';
      widget.emit('reset error', new ValidationError(invalid_error));
      widget._focusError(email_input, widget.options.i18n.t('invalid'));
    }
  }

  if (password_empty) {
    widget.emit('reset error', new ValidationError('password empty'));
    widget._focusError(password_input);
    ok = false;
  }

  if (repeat_password_empty) {
    widget.emit('reset error', new ValidationError('repeat password empty'));
    widget._focusError(repeat_password_input);
    ok = false;
  }

  if (repeat_password_input.val() !== password_input.val()) {
    widget.emit('reset error', new ValidationError('password missmatch'));
    widget._focusError(repeat_password_input, widget.options.i18n.t('mustMatch'));
    ok = false;
  }

  return ok;
};
Esempio n. 9
0
function selector(el){
  var classname = trim(el.className.baseVal ? el.className.baseVal : el.className);
  var i = el.parentNode && 9 == el.parentNode.nodeType ? -1 : index(el);

  return el.tagName.toLowerCase()
    + (el.id ? '#' + el.id : '')
    + (classname ? classname.replace(/^| +/g, '.') : '')
    + (~i ? ':nth-child(' + (i + 1) + ')' : '');
}
Esempio n. 10
0
		return str.replace(/\{>([^}]+)\}/g, function(_, expr) {
			var name = trim(expr),
			val = partials[name];
			if(val){
				val = marc(val);
				if(val.substring(0, 3) === '<p>') val = val.substring(3, val.length - 5);
				return val;
			}
		});
CreateModal.prototype._getName = function() {
  var nameInput = this.el.querySelector('input');

  var name = nameInput.value;
  name = trim(name);
  name = _.escape(name);

  return name;
};
Esempio n. 12
0
 $or: email.map(function(e) {
   return {
     accounts: {
       $elemMatch: {
         emails: trim(e).toLowerCase()
       }
     }
   };
 })
Esempio n. 13
0
 loadFromEmail: function(email, cb) {
   this.findOne({
     accounts: {
       $elemMatch: {
         emails: trim(email).toLowerCase()
       }
     }
   }, cb);
 }
Esempio n. 14
0
Identify.prototype.lastName = function() {
  var lastName = this.proxy('traits.lastName');
  if (typeof lastName === 'string') {
    return trim(lastName);
  }

  var name = this.proxy('traits.name');
  if (typeof name !== 'string') {
    return;
  }

  var space = trim(name).indexOf(' ');
  if (space === -1) {
    return;
  }

  return trim(name.substr(space + 1));
};
Esempio n. 15
0
  return function handle(element, buffer) {
    var value = trim(element.val)
    var asciiMathSymbol = moHelpers.toAsciiMath(value);

    if (typeof asciiMathSymbol == 'undefined') {
      throw new Error('Unsupported operator: ' + value)
    }

    buffer.push(asciiMathSymbol);
  };
Esempio n. 16
0
        }, function (error, response, body) {
            
            //            console.log("error && response.statusCode",error,response.statusCode,body);
            if (!error && response.statusCode == 200) {
                var arr = [];
                var result = body;
                //                console.log("body:",typeof result.hits.hits,result.hits.hits[0]._source,result.hits.hits.length);
                for(var i = 0;i < result.hits.hits.length;i++){
                    //                    if(result.hits.hits[i]._source.data.item_img != null && result.hits.hits[i]._source.data.item_img != 'http://www.esajeecom.esajee.com/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/thumbnail.jpg'){
                    if(result.hits.hits[i]._source.data.item_img != ''){
                        //                        console.log('test:',result.hits.hits[i]._source.data.product_name,result.hits.hits[i]._source.data.brand_name,result.hits.hits[i]._source.data.category_name,result.hits.hits[i]._source.data.supplier_name);
                        var br = trim(result.hits.hits[i]._source.data.brand_name);
                        var pro = trim(result.hits.hits[i]._source.data.product_name);
                        var cat = trim(result.hits.hits[i]._source.data.category_name);
                        var supp = trim(result.hits.hits[i]._source.data.supplier_name);
                        //                                                console.log('length:',br.length,pro.length,cat.length,supp.length);
                        if(br.length > 0 && pro.length > 0 && cat.length > 0 && supp.length > 0){
                            //                            console.log('test:',result.hits.hits[i]._source.data.product_name);
                            arr.push({
                                'name':result.hits.hits[i]._source.data.item_description,
                                'image':result.hits.hits[i]._source.data.item_img,
                                'price':result.hits.hits[i]._source.data.retail_price,
                                'lastpurchased':result.hits.hits[i]._source.data.last_purchased,
                                'lastpurchasedby':result.hits.hits[i]._source.data.last_purchased_by,
                                'balance':result.hits.hits[i]._source.data.balance,
                                'sold':result.hits.hits[i]._source.data.sold,
                                'product':result.hits.hits[i]._source.data.product_name,
                                'category':result.hits.hits[i]._source.data.category_name,
                                'brand':result.hits.hits[i]._source.data.brand_name,
                                'supplier':result.hits.hits[i]._source.data.supplier_name
                            });
                        }
                    }
                }
                //                console.log('array:',arr.length);
                connection.response.data = arr;
                //                console.log("response:",typeof connection.response.data,connection.response.data);
                next(connection, true);

            } else {
                next(connection, error);
            }
        });
Esempio n. 17
0
Auth0.prototype.changePassword = function (options, callback) {
  var self = this;
  var query = {
    tenant:         this._domain.split('.')[0],
    client_id:      this._clientID,
    connection:     options.connection,
    username:       trim(options.username || ''),
    email:          trim(options.email || options.username || ''),
    password:       options.password
  };


  function fail (status, resp) {
    var error = new LoginError(status, resp);
    if (callback)      return callback(error);
  }

  if (this._useJSONP) {
    return jsonp('https://' + this._domain + '/dbconnections/change_password?' + qs.stringify(query), jsonpOpts, function (err, resp) {
      if (err) {
        return fail(0, err);
      }
      return resp.status == 200 ?
              callback(null, resp.message) :
              fail(resp.status, resp.err);
    });
  }

  reqwest({
    url:     'https://' + this._domain + '/dbconnections/change_password',
    method:  'post',
    type:    'html',
    data:    query,
    crossOrigin: true,
    error: function (err) {
      fail(err.status, err.responseText);
    },
    success: function (r) {
      callback(null, r);
    }
  });
};
Esempio n. 18
0
/**
 * Split the given `str` via `delimiter`, ignoring empty items
 *
 * @api private
 * @param {String} str
 * @param {String|RegExp} delimiter
 * @return {Array}
 */
function split(str, delimiter) {
  var a = (str || '').split(delimiter);
  var b = [];

  for (var i = 0, len = a.length; i < len; i++) {
    var c = trim(a[i]);
    if (c) b.push(c);
  }

  return b;
}
Esempio n. 19
0
File: fs.js Progetto: dodo/xmppfs
State.prototype.write = function (offset, len, buf, fd, callback) {
    var err = E.OK;
    var data = trim(buf.toString('utf8')); // read the new data
    if (this.options.indexOf(data) === -1) {
        err = -E.EKEYREJECTED;
    } else {
        err = len;
        this.setState(data, 'in');
    }
    callback(err);
};
function parseStyle(value) {
  var result = {};
  var declarations = value.split(';');
  var length = declarations.length;
  var index = -1;
  var declaration;
  var prop;
  var pos;

  while (++index < length) {
    declaration = declarations[index];
    pos = declaration.indexOf(':');
    if (pos !== -1) {
      prop = camelCase(trim(declaration.slice(0, pos)));
      result[prop] = trim(declaration.slice(pos + 1));
    }
  }

  return result;
}
Esempio n. 21
0
/**
 * Parse `value` into a virtual style object.
 *
 * @param {string} value - Stringified CSS rules.
 * @return {Object.<string, string>} - Map of CSS
 *   properties mapping to CSS values.
 */
function parseStyle(value) {
    var declarations = value.split(';');
    var length = declarations.length;
    var rules = {};
    var index = -1;
    var entry;
    var property;

    while (++index < length) {
        entry = declarations[index].split(/:(.+)/);
        property = trim(entry[0]);
        value = trim(entry[1] || '');

        if (property && value) {
            rules[property] = value;
        }
    }

    return rules;
}
Esempio n. 22
0
  consumptions.createWithConsumer = function(req, res) {
    console.log("create Consumption with Consumer");

    var username = trim(req.params.username);
    var barcode = req.body.barcode;

    if(username == "Anon") {
      createAnonymousConsumtion(res, barcode);
    } else {
      createConsumtionWithUser(res, barcode, username);
    }
  }
Esempio n. 23
0
 }).on('data', function(data) {
     data = trim(data.toString());
     //                                if (typeof(Command.process) == 'function')
     //                                    data = Command.process(data);
     callback(null, {
         server: server,
         started: start,
         millisecs: new Date().getTime() - start,
         ts: new Date().getTime(),
         data: data,
     });
 }).stderr.on('data', HandleMbufferStdErr);
Esempio n. 24
0
function off(element, event, selector, callback){
  if (event.charAt(0) == '>') {
    return bindKey.off(element, trim(event.slice(1)), callback);
  }

  if (arguments.length == 4) {
    return delegate.off(element, selector, event, callback);
  }

  callback = selector;

  events.off(element, event, callback);
}
  onKeyUp(event){
    if(event.keyCode === 13 && trim(event.target.value) !=''){
      event.preventDefault();
      this.firebaseRef.push({
        message: this.state.message
      });

      this.setState({
        message: ''
      });
      console.log('Sent a new msg: ', event.target.value);
    }
  }
    onKeyUp(event) {
        if(event.keyCode === 13 && trim(event.target.value) !== '') {
            event.preventDefault();
            const content = this.state.message.trim();
            this.props.listBotsAtDylansAPI(content);
//             this.props.postToPerla(content);
            this.setState({
                message: ''
            });

            console.log('Sent a new message: ', event.target.value);
        }
    }
Esempio n. 27
0
module.exports.findByEmail = function(email, callback) {
  var query;
  if (util.isArray(email)) {
    var emails = email.map(function(e) {
      return trim(e).toLowerCase();
    });
    query = { $or: emails.map(function(e) { return {emails: e}; }) };
  } else {
    var qemail = trim(email).toLowerCase();
    query = {emails: qemail};
  }
  User.findOne(query, callback);
};
Esempio n. 28
0
Auth0.prototype.signup = function (options, callback) {
  var self = this;

  var query = xtend(
    this._getMode(),
    options,
    {
      client_id: this._clientID,
      redirect_uri: this._callbackURL,
      email: trim(options.username || options.email || ''),
      tenant: this._domain.split('.')[0]
    });

  this._addOfflineMode(query);

  function success () {
    if ('auto_login' in options && !options.auto_login) {
      if (callback) callback();
      return;
    }
    self.login(options, callback);
  }

  function fail (status, resp) {
    var error = new LoginError(status, resp);
    if (callback) return callback(error);
    throw error;
  }

  if (this._useJSONP) {
    return jsonp('https://' + this._domain + '/dbconnections/signup?' + qs.stringify(query), jsonpOpts, function (err, resp) {
      if (err) {
        return fail(0, err);
      }
      return resp.status == 200 ?
              success() :
              fail(resp.status, resp.err);
    });
  }

  reqwest({
    url:     'https://' + this._domain + '/dbconnections/signup',
    method:  'post',
    type:    'html',
    data:    query,
    success: success,
    crossOrigin: true
  }).fail(function (err) {
    fail(err.status, err.responseText);
  });
};
Esempio n. 29
0
	onKeyUp( event ) {
		if ( event.keyCode === 13 && trim( event.target.value) !== `` ) {
			event.preventDefault();

			this.firebaseRef.push({
				message: this.state.message
			});

			this.setState({
				message: ``
			});

		}
	}
Esempio n. 30
0
 callback: function(error, result, $) {
     if ($) {
         var length = $('div').find('.zplayerDiv').length;
         var title, date, desc, thumb, video1, video2, video3;
         if (length == 1) {
             //get title
             $('h1.baiviet-title').each(function(index, h1) {
                     title = trim($(h1).text());
                 })
                 //get video url
             $('div.zplayerDiv').each(function(index, div) {
                     var dataConfig = $(div).attr('data-config');
                     var arr = dataConfig.toString().split("&");
                     for (var i = 0; i < arr.length; i++) {
                         if (arr[i].indexOf('file=http://24h-video') > -1) {
                             var videos = arr[i].substring(5, arr[i].length);
                             if (videos.indexOf('***') > -1) {
                                 var videoUrl = videos.split("***");
                                 var totalVideos = videoUrl.length;
                                 if (totalVideos < 3) {
                                     video1 = videoUrl[0];
                                     video2 = videoUrl[1];
                                 }
                                 else {
                                     video1 = videoUrl[0];
                                     video2 = videoUrl[1];
                                     video3 = videoUrl[2];
                                 }
                             }
                             else {
                                 video1 = videos;
                             }
                         }
                     }
                 })
                 //get thumb
             thumb = $('img.news-image').attr('src');
             console.log('Thumb:', thumb);
             //get date
             date = $('div.baiviet-ngay').text();
             console.log('Date:', date);
             //get short desc
             desc = trim($('p.baiviet-sapo').text());
             console.log('Desc:', desc);
             //insert to DB
             db.insertHighlight(title, date, desc, thumb, video1, video2, video3);
         }
     }
 }