create the session for the user using the password strategy and returning the user JSON
178571
def create
      if env['warden'].authenticate(:password, :scope => :user)
        #return the user JSON on success
        render json: current_user, status: :created
      else
        #return error mesage in a JSON on error
        render json: {errors: {user:["Invalid email or password"]}}, status: :unprocessable_entity
      end
    end
195581
def login(request, user):
    
    session_auth_hash = ''
    if user is None:
        user = request.user
    if hasattr(user, 'get_session_auth_hash'):
        session_auth_hash = user.get_session_auth_hash()

    if SESSION_KEY in request.session:
        session_key = request.session[SESSION_KEY]
        if session_key != user.pk or (
                session_auth_hash and
                request.session.get(HASH_SESSION_KEY) != session_auth_hash):
            # To avoid reusing another user's session, create a new, empty
            # session if the existing session corresponds to a different
            # authenticated user.
            request.session.flush()
    else:
        request.session.cycle_key()
    request.session[SESSION_KEY] = user.pk
    request.session[BACKEND_SESSION_KEY] = user.backend
    request.session[USER_DATA_SESSION_KEY] = user.user_data
    request.session[HASH_SESSION_KEY] = session_auth_hash

    update_token_in_session(request.session, user.token)

    if hasattr(request, 'user'):
        request.user = user
    rotate_token(request)
    user_logged_in.send(sender=user.__class__, request=request, user=user)
332372
def create
      session = build_passwordless_session(find_authenticatable)

      if session.save
        Passwordless.after_session_save.call(session)
      end

      render
    end
798768
def _get_user(session, slug_or_user_id):
        
        user_json_items = session.fetch('users.get', user_ids=slug_or_user_id, fields=User.USER_FIELDS)
        return User.from_json(session, user_json_items[0])
1193015
def prepare(session_data={}, #pylint: disable=dangerous-default-value
                passphrase=None):
        
        if passphrase is None:
            passphrase = settings.DJAODJIN_SECRET_KEY
        return encode(session_data, passphrase,
            json_encoder=crypt.JSONEncoder)
49508
def generate_reset_password_token(user):
    
    password_hash = hash_data(user.password) if user.password else None
    data = [str(user.id), password_hash]
    return _security.reset_serializer.dumps(data)
1106970
function auth (username, password, callback) {
    return relax({
      method: 'POST',
      db: '_session',
      form: {
        name: username,
        password: password
      }
    }, callback)
  }
796239
def _login(self, username, password):
        '''
        '''
        logger.debug('login in as user "%s"' % username)
        url = self._build_url('/auth')
        payload = {'username': username, 'password': password}
        res = self._session.post(url, json=payload)
        res.raise_for_status()
        self._access_token = res.json()['access_token']
        self._session.headers.update(
            {'Authorization': 'JWT %s' % self._access_token}
        )
1041337
def post_json(session, url, json):
    
    res = session.post(url, json=json)
    if res.status_code >= 400:
        raise parse_error(res)
    return res
133830
def login
    connect! unless connected?    
    json = <<-EOF
      {
        "user_auth": {
          "user_name": "#{@user}",
           "password": "#{OpenSSL::Digest::MD5.new(@pass)}",
            "version": 2
        },
        "application": "sugarcrm_rubygem"
      }
    EOF
    json.gsub!(/^\s{6}/,'')
    response = send!(:login, json)
  end
308051
private static void insertFromJson(CqlSession session) {

    JsonObject alice = Json.createObjectBuilder().add("name", "alice").add("age", 30).build();

    JsonObject bob = Json.createObjectBuilder().add("name", "bob").add("age", 35).build();

    JsonObject aliceScores =
        Json.createObjectBuilder().add("call_of_duty", 4.8).add("pokemon_go", 9.7).build();

    JsonObject bobScores =
        Json.createObjectBuilder().add("zelda", 8.3).add("pokemon_go", 12.4).build();

    // Build and execute a simple statement
    Statement stmt =
        insertInto("examples", "json_jsr353_function")
            .value("id", literal(1))
            // client-side, the JsonObject will be converted into a JSON String;
            // then, server-side, the fromJson() function will convert that JSON string
            // into an instance of the json_jsr353_function_user user-defined type (UDT),
            // which will be persisted into the column "user"
            .value(
                "user",
                function("fromJson", literal(alice, session.getContext().getCodecRegistry())))
            // same thing, but this time converting from
            // a JsonObject to a JSON string, then from this string to a map<varchar,float>
            .value(
                "scores",
                function("fromJson", literal(aliceScores, session.getContext().getCodecRegistry())))
            .build();
    session.execute(stmt);

    // The JSON object can be a bound value if the statement is prepared
    // (subsequent calls to the prepare() method will return cached statement)
    PreparedStatement pst =
        session.prepare(
            insertInto("examples", "json_jsr353_function")
                .value("id", bindMarker("id"))
                .value("user", function("fromJson", bindMarker("user")))
                .value("scores", function("fromJson", bindMarker("scores")))
                .build());
    session.execute(
        pst.bind()
            .setInt("id", 2)
            // note that the codec requires that the type passed to the set() method
            // be always JsonStructure, and not a subclass of it, such as JsonObject
            .set("user", bob, JsonStructure.class)
            .set("scores", bobScores, JsonStructure.class));
  }
477196
def user(self, login=None):
        '''
        
        '''
        if login:
            url = '%s/user/%s' % (self.domain, login)
        else:
            url = '%s/user' % (self.domain)

        res = self.session.get(url, verify=self.session.verify)
        self._check_response(res)

        return res.json()
160152
def from_json(cls, session, photo_json):
        
        photo = cls()
        photo.id = photo_json.get('id')
        photo.album_id = photo_json.get('album_id')
        photo.owner_id = photo_json.get('owner_id')
        photo.user_id = photo_json.get('user_id')
        photo.text = photo_json.get('text')
        photo.type = "photo"
        photo.date = photo_json.get('date')
        photo.photo_75 = photo_json.get('photo_75')
        photo.photo_130 = photo_json.get('photo_130')
        photo.photo_604 = photo_json.get('photo_604')
        photo.photo_807 = photo_json.get('photo_807')
        photo.photo_1280 = photo_json.get('photo_1280')
        photo.photo_2560 = photo_json.get('photo_2560')
        photo._session = session
        return photo
453847
def create(self, username, password, tags=''):
        
        user_payload = json.dumps({
            'password': password,
            'tags': tags
        })
        return self.http_client.put(API_USER % username,
                                    payload=user_payload)
193025
def login(self, username, json_document):
        
        url = '{}u/{}'.format(self.url, username)
        make_request(
            url, method='PUT', body=json_document, timeout=self.timeout)
801716
function create(req, res, next) {
  var body = req.body;

  db.users.create(body, function(err, user) {
    if(err) { return next(err); }
    res.json(201, user);
  });
}
609712
def get_session_key(limedict):
    """"""
    url = limedict['url']
    user = limedict['username']
    password = limedict['password']
    params = {'username': user, 'password': password}
    data = set_params('get_session_key', params)
    req = requests.post(url, data=data, headers=headers)
    return {'token': req.json()['result'], 'user': user, 'url': url}