Returns a promise that fulfills iff this user id is valid.
500948
function validateAuthData(authData, config) {
  var appSecretProof = crypto.createHmac('sha256', config.appSecret).update(authData.access_token).digest('hex');
  return graphRequest('me/?access_token=' + authData.access_token + '&appsecret_proof=' + appSecretProof)
    .then((data) => {
      if (data && data.id == authData.id) {
        return;
      }
      throw new Parse.Error(
        Parse.Error.OBJECT_NOT_FOUND,
        'AccountKit auth is invalid for this user.');
    });
}
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;
    }
510676
def resolved(value):
        """"""
        p = Promise()
        p._state = 'resolved'
        p.value = value
        return p
881696
function verify(token, privateKey, audience) {
        var deferred = Q.defer();
        var options = { ignoreExpiration: true, audience: audience };

        // no token so return nothing
        if (!token) {
            return new Q();
        }

        jsonwebtoken.verify(token, privateKey, options, function (err, decodedToken) {
            err ? deferred.reject(err) : deferred.resolve(decodedToken);
        });

        return deferred.promise;
    }
1301212
function( userId, id ) {

		return this.memory.joinRoom( userId, id )
		.then( function( id ) {

			if( rooms[ id ] === undefined ) {

				rooms[ id ] = room( this.memory, id );	
			}
			
			return promise.resolve( rooms[ id ] );
		}.bind( this ));
	}
173298
function getAuthUsernameAvailable(req, res) {

    if (!req.query || !req.query.username) {
      res.status(400).send('Please provide a username');
    } else {
      var query = {
        username: req.query.username
      };

      var userCollection = authConfig.strategy === 'password' ? users :
        providerAccounts;

      userCollection.find(query).exec()
        .then(function (matchingUsers) {
          res.status(200).send({
            data: matchingUsers.length === 0
          });
        })
        .then(null, util.makeErrorResponder(res));
    }
  }
406179
def verify_verify(self, id, token):
        """"""
        return Verify().load(self.request('verify/' + str(id), params={'token': token}))
1046473
def get_user_if_exists(strategy, details, user=None, *args, **kwargs):
    """"""
    if user:
        return {'is_new': False}
    try:
        username = details.get('username')

        # Return the user if it exists
        return {
            'is_new': False,
            'user': User.objects.get(username=username)
        }
    except User.DoesNotExist:
        # Fall to the default return value
        pass

    # Nothing to return since we don't have a user
    return {}
287113
function() {
    // If the user is on a valid value, then we increment the value, but if
    // they've typed something that's not right we page through predictions
    if (this.assignment.getStatus() === Status.VALID) {
      return this.requisition.nudge(this.assignment, 1).then(function() {
        this.textChanged();
        this.focusManager.onInputChange();
        return true;
      }.bind(this));
    }

    return Promise.resolve(false);
  }
9871
def get_id_from_user(user):
    """"""
    id = r_client.hget('user-id-map', user)
    if id is None:
        id = str(uuid4())
        r_client.hset('user-id-map', user, id)
        r_client.hset('user-id-map', id, user)
    return id
738678
function requestPromisfied(options) {
  return new Promise(function (resolve, reject) {
    (0, _request2.default)(options, function (err, res) {
      if (err) {
        reject(err);
      }
      resolve(res.body);
    });
  });
}
1257463
function() {
        return new Promise(function(resolve, reject) {
            VkSdkLoginManager.authorize(function(error, result) {
                if (error) {
                    reject(error);
                } else {
                    resolve(result);
                }
            });
        });
    }
213386
def is_valid(self):
        """"""
        form = super(AuthenticateForm, self).is_valid()
        for f, error in self.errors.items():
            if f != "__all__":
                self.fields[f].widget.attrs.update({"class": "error", "placeholder": ", ".join(list(error))})
            else:
                errors = list(error)
                if "This account is inactive." in errors:
                    message = "Intranet access restricted"
                else:
                    message = "Invalid password"
                self.fields["password"].widget.attrs.update({"class": "error", "placeholder": message})

        return form
174997
private Promise<PublicKey> fetchUserPreKey(final int uid, final int keyGroupId) {
        return pickUserGroup(uid, keyGroupId)
                .flatMap(new Function<Tuple2<UserKeysGroup, UserKeys>, Promise<PublicKey>>() {
                    @Override
                    public Promise<PublicKey> apply(final Tuple2<UserKeysGroup, UserKeys> keyGroups) {
                        return api(new RequestLoadPrePublicKeys(new ApiUserOutPeer(uid, getUser(uid).getAccessHash()), keyGroupId))
                                .map(new Function<ResponsePublicKeys, PublicKey>() {
                                    @Override
                                    public PublicKey apply(ResponsePublicKeys response) {
                                        if (response.getPublicKey().size() == 0) {
                                            throw new RuntimeException("User doesn't have pre keys");
                                        }
                                        ApiEncryptionKey key = response.getPublicKey().get(0);
                                        ApiEncryptionKeySignature sig = null;
                                        for (ApiEncryptionKeySignature s : response.getSignatures()) {
                                            if (s.getKeyId() == key.getKeyId() && "Ed25519".equals(s.getSignatureAlg())) {
                                                sig = s;
                                                break;
                                            }
                                        }
                                        if (sig == null) {
                                            throw new RuntimeException("Unable to find public key on server");
                                        }

                                        byte[] keyHash = RatchetKeySignature.hashForSignature(key.getKeyId(), key.getKeyAlg(),
                                                key.getKeyMaterial());

                                        if (!Curve25519.verifySignature(keyGroups.getT1().getIdentityKey().getPublicKey(),
                                                keyHash, sig.getSignature())) {
                                            throw new RuntimeException("Key signature does not isMatch");
                                        }

                                        return new PublicKey(key.getKeyId(), key.getKeyAlg(), key.getKeyMaterial());
                                    }
                                });
                    }
                });
    }
553739
function handleUserMe(req, res, next) {
		Promise.resolve(req.locals.user || {})
		.then(function (me) {
			debug(`Handling user/me request for ${me.display_name}.`);
			res.json({
				me
			});
			next();
		}).catch(function (err) {
			debug(`Error during user/me request`, err);
			next(err);
		});
	}
57411
def is_valid(self):
        """"""

        try:
            request = self.get_oauth_request()
            client = self.get_client(request)
            params = self._server.verify_request(request, client, None)
        except Exception as e:
            raise e

        return client
818873
function verifyUsernameDoesNotExist(req, res, next) {
  var username = req.body.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 already exists, so send an HTTP 409 (Conflict)
      res.sendStatus(409);
    }
    else {
      next();
    }
  });
}