a much needed check in order to prevent developer confusion :P

This commit is contained in:
Evert Prants 2017-08-28 01:35:19 +03:00
parent 1ca055a526
commit f8990ec7a6
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
1 changed files with 5 additions and 0 deletions

View File

@ -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')
}