stormpath / express-stormpath

Build simple, secure web applications with Stormpath and Express!
http://docs.stormpath.com/nodejs/express/
Apache License 2.0
325 stars 111 forks source link

stormpathApplication.getAccounts() #619

Open peebles opened 7 years ago

peebles commented 7 years ago

I am using 4.0.0-rc4 and migrating a Stormpath app.

I am trying to find an account by email. My code

    var spapp    = app.get('stormpathApplication');
    spapp.getAccounts( { email: email }, function( err, collection ) {
      if ( err ) return cb( err );
      var accounts = [];
      collection.each( function( account, cb ) {
    accounts.push( account );
    cb();
      }, function( err ) {
    if ( err ) return cb( err );
       console.log( accounts );
    });

I have about 1000 accounts. The first problem is that getAccounts() is returning more than one account. The second problem is that it is returning only 50 accounts.

It seems like (1) the query is being ignored and (2) the collection iterator is not paging ... the default page size appears to be 50, and I only get the first page.

Am I doing something incorrectly?

peebles commented 7 years ago

Passing in { limt: 50, offset: 100 } is also ignored. Limit seems to be honored, but no matter what offset is, I always get the first page.

robertjd commented 7 years ago

Hi @peebles , that method comes from the underlying Node SDK, which is not being 100% patched for Okta.

I would suggest trying the alpha version of our Okta Node SDK:

https://github.com/okta/okta-sdk-nodejs#list-all-org-users

Please note that this module is not yet on NPM, you you will need to use the Git URL in your package.json

The Okta pagination API is different, but does support limit parameter, which can be passed to client.listUsers({limit: 100})

https://developer.okta.com/docs/api/getting_started/design_principles.html#pagination