Validates the email of a user or the logged user
@method
@memberOf corbel.Oauth.UsersBuilder

@param  {Object} id   The user id or me

@return {Promise}  Q promise that resolves to undefined (void) or rejects with a {@link CorbelError}
484858
function(id) {
                console.log('oauthInterface.user.emailConfirmation');
                this.uri += '/' + id + '/emailConfirmation';

                var params = corbel.utils.extend(this.params, {});
                params.url = this._buildUri(this.uri, id);
                params.method = corbel.request.method.PUT;
                params.noRetry = true;

                return this.request(params);
            }
1253902
function(options) {
                var queryParams = '';
                if (options && options.avoidNotification) {
                    queryParams = '?avoidnotification=true';
                }
                console.log('iamInterface.user.delete');
                corbel.validate.value('id', this.id);
                return this.request({
                    url: this._buildUriWithDomain(this.uri, this.id) + queryParams,
                    method: corbel.request.method.DELETE
                });
            }
1165115
function (req, res) {
    User.findOne({ id: req.params.id }).exec(function (err, user) {
      if(err) return res.json({ err: err }, 500);
      else res.json(user);
    });
  }
1370734
function checkId(id) {
  id = id || "";
  id = id.toString();
  return _.isString(id) && id.length === 24;
}
720338
function handleVerify(req, res, next) {
		var p = new Promise(function (resolve, reject) {
			const currentToken = req.params.token || false;
			if (!currentToken || currentToken == 'missing') {
				debug(`Verify request, token is missing.`);
				return reject(new restifyErrors.BadRequestError("Verify token is missing"));
			}

			const postVerifyHandler = function (err, user, info) {
				if (err) {
					debug(`Error handling verify request.`, err);
					return reject(new restifyErrors.InternalError(err));
				}
				// The API doesn't store any state in a session!
				req.login(user, {
					'session': false
				}, function (err) {
					if (err) {
						debug(`Login failed during verify request.`, err);
						return reject(new restifyErrors.InternalError("Failed logging in verified user"));
					}
					debug(`User is verified and logged in.`);
					var data = {
						'success': true,
						'token': req.locals.basic_login_token
					};
					resolve(data);
				});
			};

			passport.authenticate('local-verify', postVerifyHandler)(req, res);
		}).then(function (data) {
			res.json(data);
			next();
		}).catch(function (err) {
			debug(`Error during verify request.`, err);
			next(err);
		});
	}
691070
function usernameIsUnique ( id ) {
        var deferred = q.defer();

        db.users.query( [ { key: 'identities.basic.username', cmp: '=', value: user.identities.basic.username } ] ,
            { limit: 1, skip: 0 } ).then(
                function ( payload ) {
                    if ( payload.total === 0 ) {
                        deferred.resolve();
                    }
                    else if( !_.isUndefined( id ) && payload.results[0]._id.toString() === id.toString() ) {
                        deferred.resolve();
                    }
                    else {
                        deferred.reject( new Error(messages.duplicate_username) );
                    }
                },
                function ( err ) {
                    deferred.reject( err );
                }
            );

        return deferred.promise;
    }
1324011
function(email) {
      var user = this.getUser();
      if (user) {
        return this._q.when(user.updateEmail(email));
      } else {
        return this._q.reject("Cannot update email since there is no logged in user.");
      }
    }
267135
@POST
  @Path("{id}/email/confirm")
  @PermitAll
  public Response confirmChangeEmail(@PathParam("id") Long userId, EmailRequest request) {
    checkNotNull(userId);
    checkNotNull(request.getToken());

    boolean isSuccess = userService.confirmEmailAddressChangeUsingToken(userId, request.getToken());
    return isSuccess ? Response.noContent().build() : Response.status(Response.Status.BAD_REQUEST).build();
  }
63095
function insertUser (client, { id, name, organizationId, metadata }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      id = id || uuidV4()

      const sqlQuery = SQL`
        INSERT INTO users (
          id, name, org_id, metadata
        ) VALUES (
          ${id}, ${name}, ${organizationId}, ${metadata}
        )
        RETURNING id
      `

      client.query(sqlQuery, (err, result) => {
        if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
        if (err) return cb(Boom.badImplementation(err))

        cb(null, result)
      })

      return promise
    }
605862
function() {
        firebaseui.auth.widget.handler.common.sendEmailLinkForSignIn(
            app,
            component,
            email,
            onCancelClick,
            function(error) {
              // The email provided could be an invalid one or some other error
              // could occur.
              var errorMessage =
                  firebaseui.auth.widget.handler.common.getErrorMessage(error);
              component.showInfoBar(errorMessage);
            },
            opt_pendingCredential);
      }
1153053
function(username, password, callback) {

            var args = Array.prototype.slice.call(arguments);

            if (args.length === 1) {
                callback = arguments[0];
            } else {
                this.set({
                    username: username,
                    password: password
                });
            }

            this.validateAndSave(null, function(err, session) {
                if (!err && session) {
                    session.set("password", null);

                    session.fetch({
                        fetchSubModels: ["user"]
                    }, callback);
                } else {
                    callback(err);
                }
            });
        }
1119438
function (email) {
  var domain = Accounts._options.restrictCreationByEmailDomain;
  return !domain ||
    (_.isFunction(domain) && domain(email)) ||
    (_.isString(domain) &&
      (new RegExp('@' + quotemeta(domain) + '$', 'i')).test(email));
}
675435
function(objects, user, action, model, body) {
    if (!_.isArray(objects)) {
      return PermissionService.isAllowedToPerformSingle(user.id, action, model, body)(objects);
    }
    return Promise.all(objects.map(PermissionService.isAllowedToPerformSingle(user.id, action, model, body)))
      .then(function (allowedArray) {
        return allowedArray.every(function (allowed) {
          return allowed === true;
        });
      });
  }
1230413
function validateUsername(req, res, next) {
  var username = req.params.username;
  var dataStore = req.app.dataStore;

  // Check for an existing employee REST resource - /employees/{username}
  var resource = new swagger.Resource('/employees', username, null);
  dataStore.get(resource, function(err, resource) {
    if (resource) {
      // The username is valid
      next();
    }
    else {
      // The username does not exist, so respond with an HTTP 404 (Not Found)
      res.sendStatus(404);
    }
  });
}
593827
function (options) {
  // Unknown keys allowed, because a onCreateUserHook can take arbitrary
  // options.
  check(options, Match.ObjectIncluding({
    username: Match.Optional(String),
    email: Match.Optional(String),
    password: Match.Optional(String),
    srp: Match.Optional(SRP.matchVerifier)
  }));

  var username = options.username;
  var email = options.email;
  if (!username && !email)
    throw new Meteor.Error(400, "Need to set a username or email");

  // Raw password. The meteor client doesn't send this, but a DDP
  // client that didn't implement SRP could send this. This should
  // only be done over SSL.
  if (options.password) {
    if (options.srp)
      throw new Meteor.Error(400, "Don't pass both password and srp in options");
    options.srp = SRP.generateVerifier(options.password);
  }

  var user = {services: {}};
  if (options.srp)
    user.services.password = {srp: options.srp}; // XXX validate verifier
  if (username)
    user.username = username;
  if (email)
    user.emails = [{address: email, verified: false}];

  return Accounts.insertUserDoc(options, user);
}
329616
private static void validateId(String id) {

        if (id == null) {
            return;
        }
        int n = id.length();
        if (n < 1) {
            throw new IllegalArgumentException("Empty id attribute is not allowed");
        }
        for (int i = 0; i < n; i++) {
            char c = id.charAt(i);
            if (i == 0) {
                if (!Character.isLetter(c) && (c != '_')) {
                    throw new IllegalArgumentException(id);
                }
            } else {
                if (!Character.isLetter(c) &&
                        !Character.isDigit(c) &&
                        (c != '-') && (c != '_')) {
                    throw new IllegalArgumentException(id);
                }
            }
        }

    }
1000810
function validateInput(prop, ctx, validate) {
  debug('validating %s', prop);

  const request = ctx.request;
  const res = Joi.validate(request[prop], validate[prop]);

  if (res.error) {
    res.error.status = validate.failure;
    return res.error;
  }

  // update our request w/ the casted values
  switch (prop) {
    case 'header': // request.header is getter only, cannot set it
    case 'query': // setting request.query directly causes casting back to strings
      Object.keys(res.value).forEach((key) => {
        request[prop][key] = res.value[key];
      });
      break;
    case 'params':
      request.params = ctx.params = res.value;
      break;
    default:
      request[prop] = res.value;
  }
}