commento.js: default to anonymous if only option

Closes https://gitlab.com/commento/commento/-/issues/285
This commit is contained in:
Adhityaa Chandrasekar 2020-03-19 06:33:37 -04:00
parent d077241f09
commit 7f64614f60

View File

@ -86,6 +86,7 @@
var shownReply = {}; var shownReply = {};
var shownEdit = {}; var shownEdit = {};
var configuredOauths = {}; var configuredOauths = {};
var anonymousOnly = false;
var popupBoxType = "login"; var popupBoxType = "login";
var oauthButtonsShown = false; var oauthButtonsShown = false;
var sortPolicy = "score-desc"; var sortPolicy = "score-desc";
@ -572,6 +573,11 @@
} }
markdownButton.innerHTML = "<b>M &#8595;</b> &nbsp; Markdown"; markdownButton.innerHTML = "<b>M &#8595;</b> &nbsp; Markdown";
if (anonymousOnly) {
anonymousCheckbox.checked = true;
anonymousCheckbox.setAttribute("disabled", true);
}
textarea.oninput = autoExpander(textarea); textarea.oninput = autoExpander(textarea);
if (edit === true) { if (edit === true) {
onclick(submitButton, commentEdit, id); onclick(submitButton, commentEdit, id);
@ -661,7 +667,17 @@
onclick(loginText, global.loginBoxShow, null); 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 (isLocked || isFrozen) {
if (isAuthenticated || chosenAnonymous) { if (isAuthenticated || chosenAnonymous) {