How to use the phone.verified function in phone

To help you get started, we’ve selected a few phone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github steedos / object-server / server / bundle / programs / server / packages / steedos_accounts-phone.js View on Github external
}

    if (!phone) {
      throw new Meteor.Error(403, "accounts_phone_invalid");
    }

    var userId = this.userId;

    if (!userId) {
      // Get user by phone number
      var userOptions = {
        'phone.number': phone
      };

      if (checkVerified) {
        userOptions['phone.verified'] = true;
      }

      var existingUser = Meteor.users.findOne(userOptions, {
        fields: {
          '_id': 1
        }
      });

      if (existingUser) {
        userId = existingUser && existingUser._id;
      } else {
        // Create new user with phone number
        // userId = createUser({phone:phone});
        // 暂时不允许通过手机创建新账户,因为可能会跟没有配置手机号的老账户冲突
        var errMsg = TAPi18n.__('accounts_phone_user_not_found', {}, locale);
github steedos / object-server / packages / standard-objects / users.object.js View on Github external
var newNumber;
        db.users.validatePhone(userId, doc, modifier);
        if (modifier.$unset && modifier.$unset.steedos_id === "") {
            throw new Meteor.Error(400, "users_error_steedos_id_required");
        }
        modifier.$set = modifier.$set || {};
        if (modifier.$set.username) {
            db.users.validateUsername(modifier.$set.username, doc._id);
        }
        // if doc.steedos_id && modifier.$set.steedos_id
        // 	if modifier.$set.steedos_id != doc.steedos_id
        // 		throw new Meteor.Error(400, "users_error_steedos_id_readonly");
        if (userId) {
            modifier.$set.modified_by = userId;
        }
        if (modifier.$set['phone.verified'] === true) {
            newNumber = modifier.$set['phone.mobile'];
            if (!newNumber) {
                newNumber = doc.phone.mobile;
            }
            modifier.$set.mobile = newNumber;
        }
        return modifier.$set.modified = new Date();
    });
    db.users.after.update(function (userId, doc, fieldNames, modifier, options) {
github steedos / workflow / packages / steedos-accounts-phone / phone_server.js View on Github external
phone = normalizePhone(phone);
        }

        if (!phone) {
            throw new Meteor.Error(403, "accounts_phone_invalid");
        }

        var userId = this.userId;
        if (!userId) {
            // Get user by phone number
            var userOptions = {
                'phone.number': phone,
            };

            if(checkVerified){
                userOptions['phone.verified'] = true;
            }

            var existingUser = Meteor.users.findOne(userOptions, {
                fields: {
                    '_id': 1
                }
            });
            if (existingUser) {
                userId = existingUser && existingUser._id;
            } else {
                // Create new user with phone number
                // userId = createUser({phone:phone});
                // 暂时不允许通过手机创建新账户,因为可能会跟没有配置手机号的老账户冲突
                var errMsg = TAPi18n.__('accounts_phone_user_not_found', {}, locale);
                throw new Meteor.Error(403, errMsg);
            }
github steedos / object-server / packages / standard-objects / users.object.js View on Github external
db.users.validatePhone = function (userId, doc, modifier) {
        modifier.$set = modifier.$set || {};
        if (doc._id !== userId && modifier.$set["phone.number"]) {
            if (doc["phone.verified"] === true && doc["phone.number"] !== modifier.$set["phone.number"]) {
                throw new Meteor.Error(400, "用户已验证手机,不能修改");
            }
        }
    };
    db.users.before.insert(function (userId, doc) {

phone

With a given country and phone number, validate and format the phone number to E.164 standard

MIT
Latest version published 24 days ago

Package Health Score

86 / 100
Full package analysis