0
Fork 0
mirror of https://github.com/stonith404/pingvin-share.git synced 2025-01-15 01:14:27 -05:00

fix: omit invalid username characters in oidc registration

This commit is contained in:
Elias Schneider 2024-09-26 21:50:23 +02:00
parent 61edc4f4f6
commit adc4af996d
No known key found for this signature in database
GPG key ID: 07E623B294202B6C

View file

@ -108,8 +108,10 @@ export class OAuthService {
} }
private async getAvailableUsername(preferredUsername: string) { private async getAvailableUsername(preferredUsername: string) {
// only remove + and - from preferred username for now (maybe not enough) // Only keep letters, numbers, dots, and underscores. Truncate to 20 characters.
let username = preferredUsername.replace(/[+-]/g, "").substring(0, 20); let username = preferredUsername
.replace(/[^a-zA-Z0-9._]/g, "")
.substring(0, 20);
while (true) { while (true) {
const user = await this.prisma.user.findFirst({ const user = await this.prisma.user.findFirst({
where: { where: {