From 32dc6a7358a80460dd56b24663960eb9cdaa87e1 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Tue, 27 Aug 2019 18:22:36 +0200 Subject: [PATCH] GitHub signup fixes * Don't fail when profile has no name set * Use scope that can only read public profile information (no scope) * Better error handling --- integrations/github.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/integrations/github.js b/integrations/github.js index d94903a..8ab802d 100644 --- a/integrations/github.js +++ b/integrations/github.js @@ -193,7 +193,6 @@ module.exports = async function(robot, kredits) { github: { key: process.env.GITHUB_KEY, secret: process.env.GITHUB_SECRET, - scope: ['user', 'public_repo'], callback: '/kredits/signup/github' } }; @@ -235,7 +234,7 @@ module.exports = async function(robot, kredits) { if (!contributor) { let contributorAttr = {}; contributorAttr.account = req.body.account; - contributorAttr.name = user.name; + contributorAttr.name = user.name || user.login; contributorAttr.kind = "person"; contributorAttr.url = user.blog; contributorAttr.github_username = user.login; @@ -249,9 +248,10 @@ module.exports = async function(robot, kredits) { transactionHash: transaction.hash, github_username: user.login }); - }).catch((error) => { - robot.logger.error(`[hubot-kredits] Error adding contributor:`, error); - res.sendStatus(500); + }, error => { + robot.logger.error(`[hubot-kredits] Adding contributor failed: ${error}`); + res.status(422); + res.json({ error }) }); } else { res.json({