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
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
2 changed files with 13 additions and 4 deletions

View File

@ -8,12 +8,16 @@
* Builtin ConverseJS on external XMPP server: new placeholders for the room name: CHANNEL_ID, CHANNEL_NAME.
* External webchat tool: new placeholder CHANNEL_ID in the webchat url.
### Fixes
* Builtin Prosody: Fix [#63](https://github.com/JohnXLivingston/peertube-plugin-livechat/issues/63). On some old Peertube installations, there can be usernames with upper-case letters. Adding a toLowerCase() for the XMPP jid.
## v3.2.0
### Features
* Builtin Prosody: list existing rooms in the settings page
* Builtin Prosody: new settings to enable local C2S. For example, can be used with Matterbridge (thanks https://github.com/tytan652)
* Builtin Prosody: new settings to enable local C2S. For example, can be used with Matterbridge (thanks [https://github.com/tytan652](https://github.com/tytan652))
### Fixes
@ -158,7 +162,7 @@
## v1.0.5
* New buttons and logo.
* Fix: changing default value to false for every checkbox settings (Peertube bug in <=3.0.1: https://github.com/Chocobozzz/PeerTube/issues/3838).
* Fix: changing default value to false for every checkbox settings (Peertube bug in <=3.0.1: [https://github.com/Chocobozzz/PeerTube/issues/3838](https://github.com/Chocobozzz/PeerTube/issues/3838)).
## v1.0.4

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
})