From 92ed77a96678bd883027cbfb403af08a30896b62 Mon Sep 17 00:00:00 2001 From: Rain Date: Wed, 27 Apr 2022 18:03:33 +0800 Subject: [PATCH] fix: check github user with another api --- authn/github.index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/authn/github.index.js b/authn/github.index.js index 8241cb0..087dd75 100644 --- a/authn/github.index.js +++ b/authn/github.index.js @@ -51,13 +51,16 @@ function mainProcess(event, context, callback) { internalServerError('Unable to find login', callback); } var username = response.data.login; - var orgsGet = 'https://api.github.com/orgs/' + config.ORGANIZATION + '/members/' + username; + var orgsGet = 'https://api.github.com/user/orgs'; console.log("Checking ORG membership."); axios.get(orgsGet, { headers: {'Authorization': authorization} }) .then(function(response) { console.log(response); /** Set cookie upon verified membership */ - if (response.status == 204) { + if ( + response.status == 200 && + response.data.filter((x) => x.login === config.ORGANIZATION).length === 1 + ) { console.log("Setting cookie and redirecting."); const nextLocation = { "status": "302",