Current authenticated user upvotes a card
966094
def upvote
      begin
        client.post("/cards/#{id}/membersVoted", {
          value: me.id
        })
      rescue Trello::Error => e
        fail e unless e.message =~ /has already voted/i
      end

      self
    end
3338
function(user) {
        var promise;
        if (AV.User._currentUser !== user) {
          promise = AV.User.logOut();
        } else {
          promise = Promise.resolve();
        }
        return promise.then(function() {
          user._isCurrentUser = true;
          AV.User._currentUser = user;

          var json = user._toFullJSON();
          json._id = user.id;
          json._sessionToken = user._sessionToken;
          return AV.localStorage
            .setItemAsync(
              AV._getAVPath(AV.User._CURRENT_USER_KEY),
              JSON.stringify(json)
            )
            .then(function() {
              AV.User._currentUserMatchesDisk = true;
              return AV._refreshSubscriptionId();
            });
        });
      }
1310008
def handle_authenticated_user(self, response):
        
        current_user = get_user(self.request)

        ulogin, registered = ULoginUser.objects.get_or_create(
            uid=response['uid'],
            network=response['network'],
            defaults={'identity': response['identity'],
                      'user': current_user})

        if not registered:
            ulogin_user = ulogin.user
            logger.debug('uLogin user already exists')

            if current_user != ulogin_user:
                logger.debug(
                    "Mismatch: %s is not a %s. Take over it!" % (current_user,
                                                                 ulogin_user)
                )
                ulogin.user = current_user
                ulogin.save()

        return get_user(self.request), ulogin, registered
1148047
function (cb) {
                  // card key
                  var url = options.url.replace(/light=true/i, ''),
                    params = {
                      legacyCardKey: Utils.getLegacyCardKey(url, process.env.CARD_SECRET),
                      cardKey: Utils.getCardKey(url, process.env.CARD_SECRET)
                    };

                  // extract input values
                  _.each(_.keys(options.inputValues), function (key) {
                    params[key] = options.inputValues[key];
                  });

                  if (options.inputValues.token) {

                    // retrieve previously saved parameters. Add or replace params
                    DB.unlock(options.packName, options.cardName, options.inputValues.token, process.env.LOCK_KEY, function (err, payload) {
                      if (err) {
                        // Ignore error and just return the params.
                        cb(null, params);
                      }
                      else {
                        if (payload && _.isObject(payload)) {
                          _.each(_.keys(Card.inputs), function (key) {
                            if (payload[key]) {
                              params[key] = Base64.decode(payload[key]);
                            }
                          });
                        }

                        cb(null, params);
                      }
                    });
                  }
                  else {
                    cb(null, params);
                  }
                }
730105
function authenticateUser (req, res, next) {
  // Check for verified access token
  if (req.claims && req.claims.sub) {
    User.get(req.claims.sub, function (err, user) {
      if (err) {
        return next(err)
      }

      if (!user) {
        return next(new UnauthorizedError({
          realm: 'user',
          error: 'unknown_user',
          error_description: 'Unknown user',
          statusCode: 401
        }))
      }

      req.user = user
      next()
    })

  // User is not authenticated.
  } else if (!req.user) {
    next(new UnauthorizedError({
      statusCode: 401
    }))

  // User is authenticated.
  } else {
    next()
  }
}
662578
def upvote(self):
        
        data = self.get_selected_item()
        if 'likes' not in data:
            self.term.flash()
        elif getattr(data['object'], 'archived'):
            self.term.show_notification("Voting disabled for archived post", style='Error')
        elif data['likes']:
            with self.term.loader('Clearing vote'):
                data['object'].clear_vote()
            if not self.term.loader.exception:
                data['likes'] = None
        else:
            with self.term.loader('Voting'):
                data['object'].upvote()
            if not self.term.loader.exception:
                data['likes'] = True
539800
def confirm_user(self, user):
        
        if user.confirmed_at is not None:
            return False
        user.confirmed_at = self.security.datetime_factory()
        user.active = True
        self.user_manager.save(user)

        user_confirmed.send(app._get_current_object(), user=user)
        return True
698414
def vote(session, nick, pid, response):
    """"""
    if not response:
        return "You have to vote something!"
    if response == "n" or response == "nay":
        response = "no"
    elif response == "y" or response == "aye":
        response = "yes"
    poll = get_open_poll(session, pid)
    if poll is None:
        return "That poll doesn't exist or isn't active. Use !poll list to see valid polls"
    old_vote = get_response(session, pid, nick)
    if old_vote is None:
        session.add(Poll_responses(pid=pid, response=response, voter=nick))
        return "%s voted %s." % (nick, response)
    else:
        if response == old_vote.response:
            return "You've already voted %s." % response
        else:
            msg = "%s changed their vote from %s to %s." % (nick, old_vote.response, response)
            old_vote.response = response
            return msg
1021580
def OnActivateCard(self, card):
        """"""
        SimpleSCardAppEventObserver.OnActivateCard(self, card)
        self.feedbacktext.SetLabel('Activated card: ' + repr(card))
        self.transmitbutton.Enable()
1338997
function (card, cb) {

		Card.findOrCreate(card.id, card)
	    .exec(function (err, foundCard){
	      if (err) return cb(err);
	      if (foundCard.lastStripeEvent > card.lastStripeEvent) return cb(null, foundCard);
	      if (foundCard.lastStripeEvent == card.lastStripeEvent) return Card.afterStripeCustomerCardUpdated(foundCard, function(err, card){ return cb(err, card)});
	      Card.update(foundCard.id, card)
	      .exec(function(err, updatedCards){
	      	if (err) return cb(err);
	      	if (!updatedCards) return cb(null, null);
	      	Card.afterStripeCustomerCardUpdated(updatedCards[0], function(err, card){
	      		cb(err, card);
	      	});
	      });
	    });
	}
932898
def auth_as(self, user):
        """"""
        old_user = self._user
        self.auth(user)
        try:
            yield
        finally:
            self.auth(old_user)
334681
def get_user_matches(session, user_id, from_timestamp=None, limit=None):
    """"""
    return get_recent_matches(session, '{}{}/{}/Matches/games/matches/user/{}/0'.format(
        session.auth.base_url, PROFILE_URL, user_id, user_id), from_timestamp, limit)
837532
function (card) {
	if (typeof card == 'number')
		return card >= 1 && card <= deckSize ? card : undefined; // Already codified
	if (typeof card != 'string' || card.length != 2)
		return undefined; // Invalid input
	var posRank = abbr[card[0]];
	var posSuit = (abbr[card[1]] - ranks.length) >> 1;
	if (typeof posRank != 'number' || posRank >= ranks.length || posSuit < 0)
		return undefined; // Invalid characters
	return posRank * suits.length + posSuit + 1;
}
1013064
def remark_user(self, user_id, remark):
        
        return self.post(
            url="https://api.weixin.qq.com/cgi-bin/user/info/updateremark",
            data={
                "openid": user_id,
                "remark": remark
            }
        )
818834
def authenticate(self, request, **credentials):
        """"""
        from allauth.account.auth_backends import AuthenticationBackend

        self.pre_authenticate(request, **credentials)
        AuthenticationBackend.unstash_authenticated_user()
        user = authenticate(request, **credentials)
        alt_user = AuthenticationBackend.unstash_authenticated_user()
        user = user or alt_user
        if user and app_settings.LOGIN_ATTEMPTS_LIMIT:
            cache_key = self._get_login_attempts_cache_key(
                request, **credentials)
            cache.delete(cache_key)
        else:
            self.authentication_failed(request, **credentials)
        return user
945271
def get(cls, card_id, custom_headers=None):
        

        if custom_headers is None:
            custom_headers = {}

        api_client = client.ApiClient(cls._get_api_context())
        endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(),
                                                     card_id)
        response_raw = api_client.get(endpoint_url, {}, custom_headers)

        return BunqResponseCard.cast_from_bunq_response(
            cls._from_json(response_raw, cls._OBJECT_TYPE_GET)
        )
1026249
def summon(self, card):
		
		if isinstance(card, str):
			card = self.card(card, zone=Zone.PLAY)
		self.game.cheat_action(self, [Summon(self, card)])
		return card