mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-24 21:55:52 +02:00
Add support for Discord discriminators and email storage
This commit is contained in:
@@ -21,7 +21,9 @@ export interface OAuthProfile {
|
|||||||
id?: string;
|
id?: string;
|
||||||
name?: OAuthProfileName;
|
name?: OAuthProfileName;
|
||||||
username?: string;
|
username?: string;
|
||||||
|
discriminator?: string; // discord
|
||||||
displayName?: string;
|
displayName?: string;
|
||||||
|
email?: string; // discord
|
||||||
emails?: { value: string; }[];
|
emails?: { value: string; }[];
|
||||||
provider: string;
|
provider: string;
|
||||||
gender?: string;
|
gender?: string;
|
||||||
@@ -118,7 +120,9 @@ export function getProfileUrl(profile: OAuthProfile): string | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getProfileEmails(profile: OAuthProfile): string[] {
|
export function getProfileEmails(profile: OAuthProfile): string[] {
|
||||||
if (profile.emails && profile.emails.length) {
|
if (profile.provider === 'discord') {
|
||||||
|
return [profile.email as string];
|
||||||
|
} else if (profile.emails && profile.emails.length) {
|
||||||
return profile.emails.map(e => e.value);
|
return profile.emails.map(e => e.value);
|
||||||
} else if (profile._json && profile._json.attributes && profile._json.attributes.email) { // patreon
|
} else if (profile._json && profile._json.attributes && profile._json.attributes.email) { // patreon
|
||||||
return [profile._json.attributes.email];
|
return [profile._json.attributes.email];
|
||||||
@@ -128,10 +132,12 @@ export function getProfileEmails(profile: OAuthProfile): string[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getProfileUsername(profile: OAuthProfile): string | undefined {
|
export function getProfileUsername(profile: OAuthProfile): string | undefined {
|
||||||
|
if (profile.provider === 'discord') return `${profile.username}#${profile.discriminator}`;
|
||||||
return profile.username || profile.displayName || getProfileNameInternal(profile.name);
|
return profile.username || profile.displayName || getProfileNameInternal(profile.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProfileName(profile: OAuthProfile): string | undefined {
|
export function getProfileName(profile: OAuthProfile): string | undefined {
|
||||||
|
if (profile.provider === 'discord') return `${profile.username}#${profile.discriminator}`;
|
||||||
return profile.displayName || profile.username || getProfileNameInternal(profile.name);
|
return profile.displayName || profile.username || getProfileNameInternal(profile.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user