Skip to content

Create User, if not already exists? #226

Open
@Hadryan

Description

@Hadryan

Hello,
Is there any possibility to create a user if not exists?
I think the right place is here:

model.getClient = function (clientId, clientSecret, callback) {
  console.log('in getClient (clientId: ' + clientId + ', clientSecret: ' + clientSecret + ')');
  if (clientSecret === null) {
    return OAuthClientsModel.findOne({ clientId: clientId }, callback);
  }
  OAuthClientsModel.findOne({ clientId: clientId, clientSecret: clientSecret }, callback);
};

However after reading the documentations/examples and also the codes, I'd like to know can we get some optional headers inside this method for creating a new user, if not already exists? for example:

model.getClient = function (clientId, clientSecret, callback) {
...
  // if not a user, and some special headers is set in /oauth/token, then create it
  if (clientId === null && req.body.is_Admin && req.body.should_Create && req.body.admin_SomeSecret_For_UserCreation) {
    OAuthClientsModel.insert({ clientId: clientId, clientSecret: clientSecret, /* clientDetail: {clientDetail} */  }, callback);
  }
};

Is that possible at all?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions