Skip to content

Commit 2563e7b

Browse files
committed
fix: replace Promise. calls in async functions with native behaviour
1 parent cf2adba commit 2563e7b

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

lib/grant-types/client-credentials-grant-type.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,9 @@ class ClientCredentialsGrantType extends AbstractGrantType {
6969
*/
7070

7171
async saveToken(user, client, scope) {
72-
const fns = [
73-
this.validateScope(user, client, scope),
74-
this.generateAccessToken(client, user, scope),
75-
this.getAccessTokenExpiresAt(client, user, scope),
76-
];
77-
78-
const [validatedScope, accessToken, accessTokenExpiresAt] = await Promise.all(fns);
72+
const validatedScope = await this.validateScope(user, client, scope);
73+
const accessToken = await this.generateAccessToken(client, user, scope);
74+
const accessTokenExpiresAt = await this.getAccessTokenExpiresAt(client, user, scope);
7975
const token = {
8076
accessToken: accessToken,
8177
accessTokenExpiresAt: accessTokenExpiresAt,

lib/handlers/authorize-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ AuthorizeHandler.prototype.validateRedirectUri = async function(redirectUri, cli
308308
return this.model.validateRedirectUri(redirectUri, client);
309309
}
310310

311-
return Promise.resolve(client.redirectUris.includes(redirectUri));
311+
return client.redirectUris.includes(redirectUri);
312312
};
313313
/**
314314
* Get response type.

lib/handlers/token-handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ TokenHandler.prototype.handle = async function(request, response) {
7676
}
7777

7878
if (request.method !== 'POST') {
79-
return Promise.reject(new InvalidRequestError('Invalid request: method must be POST'));
79+
throw new InvalidRequestError('Invalid request: method must be POST');
8080
}
8181

8282
if (!request.is('application/x-www-form-urlencoded')) {
83-
return Promise.reject(new InvalidRequestError('Invalid request: content must be application/x-www-form-urlencoded'));
83+
throw new InvalidRequestError('Invalid request: content must be application/x-www-form-urlencoded');
8484
}
8585

8686
try {

0 commit comments

Comments
 (0)