From 3ca97fcf0eb74a6440dbbccdd4b62a2fdf210fc6 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Thu, 5 Aug 2021 11:51:16 +0200 Subject: [PATCH] Fix #63: On some old Peertube installations, there can be usernames with upper-case letters. Adding a toLowerCase() for the XMPP jid. --- CHANGELOG.md | 8 ++++++-- server/lib/routers/api.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d2473ff..cb7a6215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/server/lib/routers/api.ts b/server/lib/routers/api.ts index f0a46b8f..219795c7 100644 --- a/server/lib/routers/api.ts +++ b/server/lib/routers/api.ts @@ -117,11 +117,16 @@ async function initApiRouter (options: RegisterServerOptions): Promise { 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 })