diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index 471cdfb..6516832 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -93,7 +93,7 @@ AuthorizeHandler.prototype.handle = async function(request, response) { const requestedScope = this.getScope(request); const validScope = await this.validateScope(user, client, requestedScope); - const authorizationCode = this.generateAuthorizationCode(client, user, validScope); + const authorizationCode = await this.generateAuthorizationCode(client, user, validScope); const ResponseType = this.getResponseType(request); const codeChallenge = this.getCodeChallenge(request); diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index 5da1b39..17df316 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -563,8 +563,9 @@ describe('AuthorizeHandler integration', function() { getClient: function() { return client; }, - saveAuthorizationCode: function() { - return { authorizationCode: 12345, client: client }; + generateAuthorizationCode: async () => 'some-code', + saveAuthorizationCode: async function(code) { + return { authorizationCode: code.authorizationCode, client: client }; } }; const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); @@ -586,7 +587,7 @@ describe('AuthorizeHandler integration', function() { return handler.handle(request, response) .then(function(data) { data.should.eql({ - authorizationCode: 12345, + authorizationCode: 'some-code', client: client }); })