Fix #63: On some old Peertube installations, there can be usernames with upper-case letters. Adding a toLowerCase() for the XMPP jid.

This commit is contained in:
John Livingston
2021-08-05 11:51:16 +02:00
parent e14007f2e9
commit 3ca97fcf0e
2 changed files with 13 additions and 4 deletions

View File

@ -117,11 +117,16 @@ async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
res.sendStatus(403)
return
}
// NB 2021-08-05: Peertube usernames should be lowercase. But it seems that
// in some old installation, there can be uppercase letters in usernames.
// When Peertube checks username unicity, it does a lowercase search.
// So it feels safe to normalize usernames like so:
const normalizedUsername = user.username.toLowerCase()
const prosodyDomain = await getProsodyDomain(options)
const password: string = await prosodyRegisterUser(user.username)
const password: string = await prosodyRegisterUser(normalizedUsername)
const nickname: string | undefined = await getUserNickname(options, user)
res.status(200).json({
jid: user.username + '@' + prosodyDomain,
jid: normalizedUsername + '@' + prosodyDomain,
password: password,
nickname: nickname
})