From 7f64614f608f08e75a4a4742779b8d4d26e11774 Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Thu, 19 Mar 2020 06:33:37 -0400 Subject: [PATCH] commento.js: default to anonymous if only option Closes https://gitlab.com/commento/commento/-/issues/285 --- frontend/js/commento.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/js/commento.js b/frontend/js/commento.js index 2dfdc67..4aef5ed 100644 --- a/frontend/js/commento.js +++ b/frontend/js/commento.js @@ -86,6 +86,7 @@ var shownReply = {}; var shownEdit = {}; var configuredOauths = {}; + var anonymousOnly = false; var popupBoxType = "login"; var oauthButtonsShown = false; var sortPolicy = "score-desc"; @@ -572,6 +573,11 @@ } markdownButton.innerHTML = "M ↓   Markdown"; + if (anonymousOnly) { + anonymousCheckbox.checked = true; + anonymousCheckbox.setAttribute("disabled", true); + } + textarea.oninput = autoExpander(textarea); if (edit === true) { onclick(submitButton, commentEdit, id); @@ -661,7 +667,17 @@ onclick(loginText, global.loginBoxShow, null); - append(login, loginText); + var numOauthConfigured = 0; + Object.keys(configuredOauths).forEach(function(key) { + if (configuredOauths[key]) { + numOauthConfigured++; + } + }); + if (numOauthConfigured > 0) { + append(login, loginText); + } else if (!requireIdentification) { + anonymousOnly = true; + } if (isLocked || isFrozen) { if (isAuthenticated || chosenAnonymous) {