How to use the phone.mobile 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 / workflow / packages / steedos-accounts-phone / phone_server.js View on Github external
(user.services.phone.verify.code != code && !isMasterCode(code))) {
                    throw new Meteor.Error(403, "accounts_phone_code_invalid");
                }

                var setOptions = {
                        'phone.verified': true,
                        'phone.modified': new Date()
                    },
                    unSetOptions = {
                        'services.phone.verify': 1
                    };

                if(userId){
                    // 当用户验证绑定自己的手机号时,把手机号一起改掉,就不用再单独调用修改手机号的接口了
                    setOptions['phone.number'] = phone;
                    setOptions['phone.mobile'] = mobile;
                }
                var resetToOldToken;
                // If needs to update password
                if (newPassword) {
                    check(newPassword, passwordValidator);
                    var hashed = hashPassword(newPassword);

                    // NOTE: We're about to invalidate tokens on the user, who we might be
                    // logged in as. Make sure to avoid logging ourselves out if this
                    // happens. But also make sure not to leave the connection in a state
                    // of having a bad token set if things fail.
                    var oldToken = Accounts._getLoginToken(self.connection.id);
                    Accounts._setLoginToken(user._id, self.connection, null);
                    resetToOldToken = function() {
                        Accounts._setLoginToken(user._id, self.connection, oldToken);
                    };
github steedos / object-server / server / bundle / programs / server / packages / steedos_accounts-phone.js View on Github external
if (!user.services.phone || !user.services.phone.verify || !user.services.phone.verify.code || user.services.phone.verify.code != code && !isMasterCode(code)) {
        throw new Meteor.Error(403, "accounts_phone_code_invalid");
      }

      var setOptions = {
        'phone.verified': true,
        'phone.modified': new Date()
      },
          unSetOptions = {
        'services.phone.verify': 1
      };

      if (userId) {
        // 当用户验证绑定自己的手机号时,把手机号一起改掉,就不用再单独调用修改手机号的接口了
        setOptions['phone.number'] = phone;
        setOptions['phone.mobile'] = mobile;
      }

      var resetToOldToken; // If needs to update password

      if (newPassword) {
        check(newPassword, passwordValidator);
        var hashed = hashPassword(newPassword); // NOTE: We're about to invalidate tokens on the user, who we might be
        // logged in as. Make sure to avoid logging ourselves out if this
        // happens. But also make sure not to leave the connection in a state
        // of having a bad token set if things fail.

        var oldToken = Accounts._getLoginToken(self.connection.id);

        Accounts._setLoginToken(user._id, self.connection, null);

        resetToOldToken = function () {
github steedos / object-server / packages / standard-objects / users.object.js View on Github external
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) {

phone

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

MIT
Latest version published 4 months ago

Package Health Score

76 / 100
Full package analysis