Skip to content

Commit 9368066

Browse files
Port User.tag getter from pomelo as utility
1 parent 3134565 commit 9368066

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

assets/openapi.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7627,6 +7627,9 @@
76277627
"type": "string"
76287628
}
76297629
},
7630+
"tag": {
7631+
"type": "string"
7632+
},
76307633
"id": {
76317634
"type": "string"
76327635
}
@@ -7658,6 +7661,7 @@
76587661
"security_keys",
76597662
"sessions",
76607663
"system",
7664+
"tag",
76617665
"username",
76627666
"verified",
76637667
"webauthn_enabled"

assets/schemas.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8097,6 +8097,9 @@
80978097
"type": "string"
80988098
}
80998099
},
8100+
"tag": {
8101+
"type": "string"
8102+
},
81008103
"id": {
81018104
"type": "string"
81028105
}
@@ -8129,6 +8132,7 @@
81298132
"security_keys",
81308133
"sessions",
81318134
"system",
8135+
"tag",
81328136
"username",
81338137
"verified",
81348138
"webauthn_enabled"

src/api/routes/auth/forgot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ router.post(
6868

6969
if (user && user.email) {
7070
Email.sendResetPassword(user, user.email).catch((e) => {
71-
console.error(`Failed to send password reset email to ${user.username}#${user.discriminator} (${user.id}): ${e}`);
71+
console.error(`Failed to send password reset email to ${user.tag} (${user.id}): ${e}`);
7272
});
7373
}
7474
},

src/api/routes/auth/verify/resend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ router.post(
5656
return res.sendStatus(204);
5757
})
5858
.catch((e) => {
59-
console.error(`Failed to send verification email to ${user.username}#${user.discriminator}: ${e}`);
59+
console.error(`Failed to send verification email to ${user.tag}: ${e}`);
6060
throw new HTTPError("Failed to send verification email", 500);
6161
});
6262
},

src/util/entities/User.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ export class User extends BaseClass {
245245
}
246246
}
247247

248+
public get tag(): string {
249+
//const { uniqueUsernames } = Config.get().general;
250+
const uniqueUsernames = false;
251+
252+
return uniqueUsernames ? this.username : `${this.username}#${this.discriminator}`;
253+
}
254+
248255
static async register({
249256
email,
250257
username,
@@ -310,7 +317,7 @@ export class User extends BaseClass {
310317
// send verification email if users aren't verified by default and we have an email
311318
if (!Config.get().defaults.user.verified && email) {
312319
await Email.sendVerifyEmail(user, email).catch((e) => {
313-
console.error(`Failed to send verification email to ${user.username}#${user.discriminator}: ${e}`);
320+
console.error(`Failed to send verification email to ${user.tag}: ${e}`);
314321
});
315322
}
316323

0 commit comments

Comments
 (0)