From 69cdd2c1e9ebe83056bf50ff72e692626044ccc5 Mon Sep 17 00:00:00 2001 From: Maximilian Gaedig <38767445+MaximilianGaedig@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:17:59 +0200 Subject: [PATCH 1/2] Fix generateAuthorizationCode not being awaited --- lib/handlers/authorize-handler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From f198623a91e1d1c877a08c43793209708863fa80 Mon Sep 17 00:00:00 2001 From: Maximilian Gaedig Date: Wed, 2 Aug 2023 15:54:07 +0200 Subject: [PATCH 2/2] Update authorization_code test --- test/integration/handlers/authorize-handler_test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 }); })