Skip to content

Commit a7ad1a2

Browse files
kabelalexr00
andauthored
Allow verified GitHub emails when none are private (#6921)
See #6916. If users haven't opted-in to use private email, still allow all secondary email addresses to be used. The REST response shows these email records with `"visibility": null`. Co-authored-by: Alex Ross <38270282+alexr00@users.noreply.github.com>
1 parent 5d17ca2 commit a7ad1a2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/github/githubRepository.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,10 @@ export class GitHubRepository extends Disposable {
897897
const { data } = await octokit.call(octokit.api.users.listEmailsForAuthenticatedUser, {});
898898
Logger.debug(`Fetch authenticated user emails - done`, this.id);
899899
// sort the primary email to the first index
900-
return data.filter(email => email.visibility === 'public' || email.email.toLowerCase().endsWith('@users.noreply.github.com')).sort((a, b) => +b.primary - +a.primary).map(email => email.email);
900+
const hasPrivate = data.some(email => email.visibility === 'private');
901+
return data.filter(email => hasPrivate ? email.email.endsWith('@users.noreply.github.com') : email.verified)
902+
.sort((a, b) => +b.primary - +a.primary)
903+
.map(email => email.email);
901904
} catch (e) {
902905
Logger.error(`Unable to fetch authenticated user emails: ${e}`, this.id);
903906
return [];

0 commit comments

Comments
 (0)