Fix handle length checking for auth and register.

This commit is contained in:
yukirij 2024-10-13 10:29:32 -07:00
parent 8c6a3c3993
commit cec083ac96

View File

@ -42,8 +42,12 @@ const SCENES = {
let container = document.createElement("section"); let container = document.createElement("section");
let form = document.createElement("form"); let form = document.createElement("form");
let tb_handle = UI.textbox("handle", "");
tb_handle.setAttribute("maxlength", 24);
form.appendChild(UI.table(null, [ form.appendChild(UI.table(null, [
[ UI.label(LANG("handle"), "handle"), UI.textbox("handle", "") ], [ UI.label(LANG("handle"), "handle"), tb_handle ],
[ UI.label(LANG("secret"), "secret"), UI.password("secret") ], [ UI.label(LANG("secret"), "secret"), UI.password("secret") ],
[ UI.label(LANG("invitation"), "code"), UI.password("code") ], [ UI.label(LANG("invitation"), "code"), UI.password("code") ],
])); ]));
@ -64,7 +68,7 @@ const SCENES = {
code.removeAttribute("class"); code.removeAttribute("class");
event.target.removeAttribute("class"); event.target.removeAttribute("class");
if(handle.value.length > 0 && secret.value.length > 0 && code.value.length > 0) { if(handle.value.length > 0 && handle.value.length < 24 && secret.value.length > 0 && code.value.length > 0) {
event.target.setAttribute("disabled", ""); event.target.setAttribute("disabled", "");
let enc = new TextEncoder(); let enc = new TextEncoder();
@ -82,7 +86,7 @@ const SCENES = {
enc_code, enc_code,
]); ]);
} else { } else {
if(handle.value.length == 0) { handle.setAttribute("class", "error"); } if(handle.value.length == 0 || handle.value.length > 24) { handle.setAttribute("class", "error"); }
if(secret.value.length == 0) { secret.setAttribute("class", "error"); } if(secret.value.length == 0) { secret.setAttribute("class", "error"); }
if(code.value.length == 0) { code.setAttribute("class", "error"); } if(code.value.length == 0) { code.setAttribute("class", "error"); }
} }
@ -144,7 +148,7 @@ const SCENES = {
let form = document.createElement("form"); let form = document.createElement("form");
let tb_handle = UI.textbox("handle", ""); let tb_handle = UI.textbox("handle", "");
tb_handle.setAttribute("maxlength", 18); tb_handle.setAttribute("maxlength", 24);
form.appendChild(UI.table(null, [ form.appendChild(UI.table(null, [
[ UI.label(LANG("handle"), "handle"), tb_handle ], [ UI.label(LANG("handle"), "handle"), tb_handle ],
@ -165,7 +169,7 @@ const SCENES = {
secret.removeAttribute("class"); secret.removeAttribute("class");
event.target.removeAttribute("class"); event.target.removeAttribute("class");
if(handle.value.length > 0 && secret.value.length > 0) { if(handle.value.length > 0 && handle.value.length <= 24 && secret.value.length > 0) {
event.target.setAttribute("disabled", ""); event.target.setAttribute("disabled", "");
let enc = new TextEncoder(); let enc = new TextEncoder();
@ -180,7 +184,7 @@ const SCENES = {
enc_secret, enc_secret,
]); ]);
} else { } else {
if(handle.value.length == 0) { handle.setAttribute("class", "error"); } if(handle.value.length == 0 || handle.value.length > 24) { handle.setAttribute("class", "error"); }
if(secret.value.length == 0) { secret.setAttribute("class", "error"); } if(secret.value.length == 0) { secret.setAttribute("class", "error"); }
} }
}); });