Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
fix: check github user with another api
Browse files Browse the repository at this point in the history
  • Loading branch information
12ain committed Apr 27, 2022
1 parent 8c16c21 commit 92ed77a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions authn/github.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 92ed77a

Please sign in to comment.