Allow empty login (#232)

This commit is contained in:
Erayd
2021-01-01 01:51:13 +13:00
committed by GitHub
parent 63935b9f03
commit d2d2468f2a
2 changed files with 12 additions and 2 deletions

View File

@@ -895,6 +895,8 @@ async function parseFields(settings, login) {
throw new Error(JSON.stringify(response)); // TODO handle host error throw new Error(JSON.stringify(response)); // TODO handle host error
} }
var allowEmpty = ["login"];
// save raw data inside login // save raw data inside login
login.raw = response.data.contents; login.raw = response.data.contents;
@@ -917,7 +919,7 @@ async function parseFields(settings, login) {
} }
// split key / value & ignore non-k/v lines // split key / value & ignore non-k/v lines
var parts = line.match(/^(.+?):(.+)$/); var parts = line.match(/^(.+?):(.*)$/);
if (parts === null) { if (parts === null) {
return; return;
} }
@@ -925,7 +927,7 @@ async function parseFields(settings, login) {
.slice(1) .slice(1)
.map((value) => value.trim()) .map((value) => value.trim())
.filter((value) => value.length); .filter((value) => value.length);
if (parts.length != 2) { if (!parts.length) {
return; return;
} }
@@ -935,6 +937,9 @@ async function parseFields(settings, login) {
Array.isArray(login.fields[key]) && Array.isArray(login.fields[key]) &&
login.fields[key].includes(parts[0].toLowerCase()) login.fields[key].includes(parts[0].toLowerCase())
) { ) {
if (parts.length < 2 && !allowEmpty.includes(key)) {
return;
}
login.fields[key] = parts[1]; login.fields[key] = parts[1];
break; break;
} }

View File

@@ -433,6 +433,11 @@
* @return bool Whether the update succeeded * @return bool Whether the update succeeded
*/ */
function update(field, value, form) { function update(field, value, form) {
if (value === undefined) {
// undefined values should not be filled, but are always considered successful
return true;
}
if (!value.length) { if (!value.length) {
return false; return false;
} }