Skip to content

Commit

Permalink
Merge pull request #3 from is-a-dev/wdhdev/filter-noreply
Browse files Browse the repository at this point in the history
filter users.noreply.github.com emails
  • Loading branch information
wdhdev authored Jul 20, 2024
2 parents fa1e92f + 3d04a5a commit 67bdcf8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const fetch = require("node-fetch");

module.exports = async (req, res) => {
const code = req.query.code;
const GITHUB_ID = process.env.GITHUB_ID;

if (!code) {
return res.status(400).json({ error: "No code provided" });
Expand Down
8 changes: 6 additions & 2 deletions src/routes/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ module.exports = async (req, res) => {
const emails = user.emails;
const message = 'test message';

return res.render("profile", { username, user_id, emails, message, error: false, user: user });
}
let filteredEmails = emails.filter(function(e) {
return e.verified && !e.email.endsWith("@users.noreply.github.com");
})

return res.render("profile", { username, user_id, emails: filteredEmails, message, error: false, user: user });
}
6 changes: 5 additions & 1 deletion src/util/gitAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ async function authenticateGithub(code) {
},
);

const emails = await emailResponse.json();
let emails = await emailResponse.json();

emails = emails.filter(function(e) {
return e.verified && !e.email.endsWith("@users.noreply.github.com");
});

return { username, user_id, emails };
}
Expand Down

0 comments on commit 67bdcf8

Please sign in to comment.