diff --git a/lib/identity-provider.js b/lib/identity-provider.js index 5f25fcfbb..31b95cd40 100644 --- a/lib/identity-provider.js +++ b/lib/identity-provider.js @@ -515,16 +515,32 @@ IdentityProvider.prototype.post = function (req, res, next) { debug('Create account with settings ', options) waterfall([ - function (callback) { - if (options.spkac && options.spkac.length > 0) { - spkac = new Buffer(stripLineEndings(options.spkac), 'utf-8') - webid('tls').generate({ - spkac: spkac, - agent: agent // TODO generate agent - }, callback) - } else { + (callback) => { + if (this.auth !== 'oidc') { + return callback() + } + + const oidc = req.app.locals.oidc + return oidc.client.users + .create({ + email: options.email, + profile: agent, + name: options.name, + password: options.password + }) + .then(() => callback()) + .catch(callback) + }, + (callback) => { + if (!(this.auth === 'tls' && options.spkac && options.spkac.length > 0)) { return callback(null, false) } + + spkac = new Buffer(stripLineEndings(options.spkac), 'utf-8') + webid('tls').generate({ + spkac: spkac, + agent: agent // TODO generate agent + }, callback) }, function (newCert, callback) { cert = newCert