From f8990ec7a6938d8d64f31c6bbc2b90aba159bb29 Mon Sep 17 00:00:00 2001 From: Evert Date: Mon, 28 Aug 2017 01:35:19 +0300 Subject: [PATCH] a much needed check in order to prevent developer confusion :P --- server/api/oauth2/controller/tokens/authorizationCode.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/api/oauth2/controller/tokens/authorizationCode.js b/server/api/oauth2/controller/tokens/authorizationCode.js index 53582c6..1f9a66b 100644 --- a/server/api/oauth2/controller/tokens/authorizationCode.js +++ b/server/api/oauth2/controller/tokens/authorizationCode.js @@ -7,9 +7,14 @@ module.exports = async (oauth2, client, providedCode, redirectUri) => { let code = null + if (!providedCode) { + throw new error.InvalidRequest('code is mandatory for authorization_code grant type') + } + try { code = await oauth2.model.code.fetchByCode(providedCode) } catch (err) { + console.error(err) throw new error.ServerError('Failed to call code.fetchByCode function') }