From 6fd87cb3d411123f789b8b0ec767fe5c7f6583d3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 25 Mar 2024 17:30:54 +0100 Subject: [PATCH] feat(UX): Show a warning when bruteforce protection is throttling Signed-off-by: Joas Schilling --- src/services/participantsService.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/services/participantsService.js b/src/services/participantsService.js index 9ffa14d62df..eaf65da3f58 100644 --- a/src/services/participantsService.js +++ b/src/services/participantsService.js @@ -21,6 +21,9 @@ */ import axios from '@nextcloud/axios' +import { + showWarning +} from '@nextcloud/dialogs' import { generateOcsUrl, } from '@nextcloud/router' @@ -48,6 +51,20 @@ const joinConversation = async ({ token, forceJoin = false }, options) => { force: forceJoin, }, options) + if (response.headers.get('X-Nextcloud-Bruteforce-Throttled')) { + console.error( + 'Remote address is bruteforce throttled: ' + + response.headers.get('X-Nextcloud-Bruteforce-Throttled') + + ' (Request ID: ' + response.headers.get('X-Request-ID') + ')' + ) + const throttleMs = parseInt(response.headers.get('X-Nextcloud-Bruteforce-Throttled'), 10) + if (throttleMs > 5000) { + showWarning( + t('spreed', 'Your requests are throttled at the moment due to brute force protection') + ) + } + } + // FIXME Signaling should not be synchronous await signalingJoinConversation(token, response.data.ocs.data.sessionId)