Skip to content

Commit

Permalink
Functionality for login credential sanitation on app deletion modal.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed May 8, 2024
1 parent 2d529d4 commit 027e6d1
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions scripts/appsec/settings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
const showError = (message)=> {
$("#deletion-error").removeClass("d-none")
$("#deletion-error").addClass("d-block");
$("#deletion-error").html(message);
}, hideError = ()=> {
$("#deletion-error").removeClass("d-block");
$("#deletion-error").addClass("d-none");
};

const deleteBtn = RotatingButton("#delete-btn");
$("#delete-btn").click(()=> {
const username = $("#deletion-username").val();
const password = $("#deletion-password").val();
let hasError = false;

deleteBtn.show();
hideError();

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

if(!password ||
password === "" ||
!isStrongPassword(password)) {
showError("Invalid password string.");
hasError = true;
}

if(hasError) {
deleteBtn.hide();
return;
}
});

$("#show-delete-modal").click(()=> {
$("#deletion-username").val("");
$("#deletion-password").val("");

hideError();
$("#delete-modal").modal("show");
});

$("#settings-save").click(()=> {
let name = $("#app-name").val(),
description = $("#app-desc").val();
Expand Down

0 comments on commit 027e6d1

Please sign in to comment.