save user by a given id
        http://getstarted.sailthru.com/api/user
7864
def save_user(self, idvalue, options=None):
        
        options = options or {}
        data = options.copy()
        data['id'] = idvalue
        return self.api_post('user', data)
813674
def user_save_event(user):
    
    msg = 'User ({}){} updated/saved'.format(user.id, user.email)
    current_app.logger.info(msg)
1336129
def update_user(self, user, username=None, first_name=None, last_name=None):
		""""""
		
		if not isinstance(user, User):
			raise ValueError
		args = locals()
		url = api_url+'users/'+str(user.id)+'/'
		payload = {}
		for i in args:
			if args[i] is not None and i not in ['self', 'user']:
				payload[i] = args[i]
		r = requests.patch(url, data=json.dumps(payload), headers=self.headers)
		print(request_status(r))
		r.raise_for_status()
		return User(r.json())
31800
def create_user(name, email, datum = nil)
      current_path = '/api/v1/users'
      payload = { name: name, mail: email }
      payload.merge!(datum) unless datum.nil?
      @conn.post(current_path, payload.to_json)
    end
325317
function createUser (req, res, next) {
    User.insert(req.body, { private: true }, function (err, user) {
      if (err) {
        res.render('signup', {
          params: qs.stringify(req.body),
          request: req.body,
          providers: settings.providers,
          error: err.message
        })
      } else {
        authenticator.dispatch('password', req, res, next, function (err, user, info) {
          if (err) { return next(err) }
          if (!user) {
          } else {
            authenticator.login(req, user)
            req.sendVerificationEmail =
              req.provider.emailVerification.enable
            req.flash('isNewUser', true)
            next()
          }
        })
      }
    })
  }
159679
def user_update(self, username, data):
        
        url = 'rest/api/2/user?username={0}'.format(username)
        return self.put(url, data=data)
1212255
def get_user(self, id):
        
        self.assert_has_permission('scim.read')
        return self._get(self.uri + '/Users/%s' % (id))
1027113
def get_user_by_key(id, key, fields = {})
      data = {
          'id' => id,
          'key' => key,
          'fields' => fields
      }
      api_get(:user, data)
    end
1321397
def edituser(self, user_id, **kwargs):
        
        data = {}

        if kwargs:
            data.update(kwargs)

        request = requests.put(
            '{0}/{1}'.format(self.users_url, user_id),
            headers=self.headers, data=data, timeout=self.timeout, verify=self.verify_ssl, auth=self.auth)

        if request.status_code == 200:
            return request.json()
        else:
            return False
936010
def save(self, obj, run_id):
        
        id_code = self.generate_save_identifier(obj, run_id)
        self.store.save(obj, id_code)
813742
def create_user(user, opts = {})
      data, _status_code, _headers = create_user_with_http_info(user, opts)
      return data
    end
537688
async def create(cls, user_id: Union[int, str],
                     is_active: bool = True,
                     is_admin: bool = False,
                     resource_policy: str = None,
                     rate_limit: int = None,
                     fields: Iterable[str] = None) -> dict:
        '''
        
        '''
        if fields is None:
            fields = ('access_key', 'secret_key')
        uid_type = 'Int!' if isinstance(user_id, int) else 'String!'
        q = 'mutation($user_id: {0}, $input: KeyPairInput!) {{'.format(uid_type) + \
            '  create_keypair(user_id: $user_id, props: $input) {' \
            '    ok msg keypair { $fields }' \
            '  }' \
            '}'
        q = q.replace('$fields', ' '.join(fields))
        variables = {
            'user_id': user_id,
            'input': {
                'is_active': is_active,
                'is_admin': is_admin,
                'resource_policy': resource_policy,
                'rate_limit': rate_limit,
            },
        }
        rqst = Request(cls.session, 'POST', '/admin/graphql')
        rqst.set_json({
            'query': q,
            'variables': variables,
        })
        async with rqst.fetch() as resp:
            data = await resp.json()
            return data['create_keypair']
16633
def user(id, &callback)
      http(:get, "/users/#{id}.json") do |data, http|
        Firering::User.instantiate(self, data, :user, &callback)
      end
    end
226105
def save_data(self,session, exp_id, content):
    ''''''
    from expfactory.database.models import (
        Participant,
        Result
    )
    subid = session.get('subid')
    token = session.get('token') 

    self.logger.info('Saving data for subid %s' % subid)    

    # We only attempt save if there is a subject id, set at start
    if subid is not None:
        p = Participant.query.filter(Participant.id == subid).first() # better query here

        # Does 
        if self.headless and p.token != token:
            self.logger.warning('%s attempting to use mismatched token [%s] skipping save' %(p.id, token))
        elif self.headless and p.token.endswith(('finished','revoked')):
            self.logger.warning('%s attempting to use expired token [%s] skipping save' %(p.id, token))
        else:

            # Preference is to save data under 'data', otherwise do all of it
            if "data" in content:
                content = content['data']

            result = Result(data=content,
                            exp_id=exp_id,
                            participant_id=p.id) # check if changes from str/int

            # Create and save the result
            self.session.add(result)
            p.results.append(result)
            self.session.commit()

            self.logger.info("Save [participant] %s [result] %s" %(p, result))
1202760
def save_state(internal_request, state):
        
        state_data = {"hash_type": internal_request.user_id_hash_type}
        state[UserIdHasher.STATE_KEY] = state_data
263678
function putAuthUser(req, res) {
    var query;
    var update;

    // Check if the user is actually logged in. We should try to update info
    // for an anonymous user.
    if (!(req.user && req.user.data)) {
      res.status(401).send('Not authenticated');

      return;
    }

    // For right now, we do not allow the user to change their username if it
    // has been set before.
    if (req.user.username) {
      res.status(422).send(
        'You cannot change the user name of a registered user.');
      return;
    }

    // Setup and execute an update query.
    query = {
      provider: req.user.data.provider,
      idWithProvider: req.user.data.idWithProvider
    };
    update = {
      username: req.body.username
    };

    providerAccounts.update(query, update).exec()
      .then(function () {

        // Now we need to update user's data in the session. The simplest way
        // to do that is to first get the current user's data.
        return oauth.getUserFromProfile(providerAccounts, req.user.data)
          .then(function (userRecord) {
            if (!userRecord) {
              throw new Error('Could not get user record.');
            }
            // Once we have the userRecord, we try to update the session.
            if (authConfig.maintenance === 'cookie') {
              req.login(userRecord, function (error) {
                if (error) {
                  throw error;
                } else {
                  res.status(200).send(userRecord);
                }
              });
            } else {
              // generate a new token
              var secrets = config.getConfig('secrets');
              var currentToken = req.headers.authorization.replace(
                'Bearer ', '');
              var decodedToken = jwt.decode(currentToken);

              var expiresInMinutes = 60;
              decodedToken.data.username = userRecord.data.username;
              var newToken = generateToken(decodedToken.data,
                expiresInMinutes,
                secrets.authTokenSecret);

              userRecord.meta = userRecord.meta || {};
              userRecord.meta.token = newToken;
              userRecord.meta.expires = getExpirationTime(
                expiresInMinutes);

              log.debug('getNewToken requested with: ', currentToken);
              log.debug('token decoded as :', decodedToken);


              res.status(200).send(userRecord);
            }
          });
      })
      .then(null, util.makeErrorResponder(res));
  }
804671
def add_user(self, user, **kwargs):
        """"""
        if isinstance(user, User):
            user = user['id']

        assert isinstance(user, six.string_types)

        endpoint = '{0}/{1}/users/{2}'.format(
            self.endpoint,
            self['id'],
            user,
        )
        result = self.request('PUT', endpoint=endpoint, query_params=kwargs)
        return result