mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 12:25:16 +00:00
Perform a request over the API to fetch security information
This commit is contained in:
@ -41,7 +41,84 @@ ComunicWeb.pages.settings.sections.security = {
|
||||
class: "box-body"
|
||||
});
|
||||
|
||||
|
||||
//Append the form to query user password
|
||||
this._append_form_prompt_user_password(boxBody);
|
||||
},
|
||||
|
||||
/**
|
||||
* Append a form to prompt user password
|
||||
*
|
||||
* @param {HMTLElement} target The target for the form
|
||||
*/
|
||||
_append_form_prompt_user_password: function(target){
|
||||
|
||||
//Create form contener (allows easier manipulations then)
|
||||
var formContener = createElem2({
|
||||
appendTo: target,
|
||||
type: "div",
|
||||
class: "prompt-user-password"
|
||||
});
|
||||
|
||||
//Add title
|
||||
createElem2({
|
||||
appendTo: formContener,
|
||||
type: "h4",
|
||||
innerHTML: "Password required"
|
||||
});
|
||||
|
||||
//Add explanation
|
||||
createElem2({
|
||||
appendTo: formContener,
|
||||
type: "p",
|
||||
innerHTML: "In order to protect these sensitive information, your password is required to access this page."
|
||||
});
|
||||
|
||||
//User password form
|
||||
var passwordInput = createFormGroup({
|
||||
target: formContener,
|
||||
label: "Your password",
|
||||
placeholder: "Your password",
|
||||
type: "password"
|
||||
});
|
||||
|
||||
//Add submit button
|
||||
var sendButton = createElem2({
|
||||
appendTo: formContener,
|
||||
type: "div",
|
||||
class: "btn btn-primary submit-form",
|
||||
innerHTML: "Submit"
|
||||
});
|
||||
|
||||
//Make submit button lives
|
||||
sendButton.onclick = function(){
|
||||
|
||||
//Check the validity of the input
|
||||
if(!ComunicWeb.common.formChecker.checkInput(passwordInput, true)){
|
||||
notify("Please input your password !", "danger");
|
||||
return;
|
||||
}
|
||||
|
||||
//Hide send button
|
||||
sendButton.style.visibility = "hide";
|
||||
|
||||
//Perform a request over the server to fetch security settings
|
||||
ComunicWeb.components.settings.interface.getSecurity(passwordInput.value, function(result){
|
||||
|
||||
//Show send button
|
||||
sendButton.style.visibility = "visible";
|
||||
|
||||
//Check for errors
|
||||
if(result.error){
|
||||
notify("An error occured while retrieving security settings! Please check your password...", "danger");
|
||||
return;
|
||||
}
|
||||
|
||||
//Remove password input form
|
||||
emptyElem(formContener);
|
||||
|
||||
//Show security information update form
|
||||
|
||||
});
|
||||
};
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user