Skip to content

Commit

Permalink
Share access modal input validations.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Jul 22, 2024
1 parent 96f1a44 commit 22b1a20
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions scripts/appsec/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,39 @@ $("#remove-btn").click(()=> {
});

$("#share-btn").click(()=> {
let email = $("#share-email").val(),
username = $("#share-username").val(),
password = CryptoJS.MD5($("#share-password").val()).toString();

if(!username ||
username === "" ||
!/^[a-zA-Z0-9_]+$/.test(username)) {
showError("share", "Invalid username string.");
return;
}

if(!password ||
password === "" ||
!/^[a-f0-9]{32}$/.test(password)) {
showError("share", "Invalid password string.");
return;
}

if(!email ||
email.length == 0 ||
!/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(email)) {
showError("share", "Invalid email address.");
return;
}

$.post(
"side/apps.php?share_app",
{
api_key: App.appKey,
api_id: App.appId,
uname: $("#share-username").val(),
pword: CryptoJS.MD5($("#share-password").val()).toString(),
email: App.email
uname: username,
pword: password,
email: email
},
(r)=> {
hideError("share");
Expand Down

0 comments on commit 22b1a20

Please sign in to comment.