Skip to content

Commit 47916a7

Browse files
authored
fix: await generateAuthorizationCode in authorize-handler
Merge pull request #203 from MaximilianGaedig/patch-1 thanks to @MaximilianGaedig
2 parents cc643fe + f198623 commit 47916a7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/handlers/authorize-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ AuthorizeHandler.prototype.handle = async function(request, response) {
9393

9494
const requestedScope = this.getScope(request);
9595
const validScope = await this.validateScope(user, client, requestedScope);
96-
const authorizationCode = this.generateAuthorizationCode(client, user, validScope);
96+
const authorizationCode = await this.generateAuthorizationCode(client, user, validScope);
9797

9898
const ResponseType = this.getResponseType(request);
9999
const codeChallenge = this.getCodeChallenge(request);

test/integration/handlers/authorize-handler_test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,9 @@ describe('AuthorizeHandler integration', function() {
563563
getClient: function() {
564564
return client;
565565
},
566-
saveAuthorizationCode: function() {
567-
return { authorizationCode: 12345, client: client };
566+
generateAuthorizationCode: async () => 'some-code',
567+
saveAuthorizationCode: async function(code) {
568+
return { authorizationCode: code.authorizationCode, client: client };
568569
}
569570
};
570571
const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model });
@@ -586,7 +587,7 @@ describe('AuthorizeHandler integration', function() {
586587
return handler.handle(request, response)
587588
.then(function(data) {
588589
data.should.eql({
589-
authorizationCode: 12345,
590+
authorizationCode: 'some-code',
590591
client: client
591592
});
592593
})

0 commit comments

Comments
 (0)