diff --git a/rockstar/rockstar.js b/rockstar/rockstar.js index 40d86d0d..52f57b38 100644 --- a/rockstar/rockstar.js +++ b/rockstar/rockstar.js @@ -280,6 +280,41 @@ event.preventDefault(); }; }); + + createDiv("Expire Password", mainPopup, function () { + const expirePasswordPopup = createPopup("Expire Password"); + const expirePasswordForm = expirePasswordPopup[0].appendChild(document.createElement("form")); // Cuz "
" didn't work. + expirePasswordForm.innerHTML = "
New password will be required at next login

"; + expirePasswordForm.onsubmit = function (event) { + const url = `/api/v1/users/${userId}/lifecycle/expire_password?tempPassword=false`; + postJSON({url}) + .then(() => expirePasswordPopup.html("Password expired.")) + .fail(jqXHR => expirePasswordPopup.html(e(jqXHR.responseJSON.errorCauses[0].errorSummary))); + event.preventDefault(); + }; + }); + + createDiv("Set Recovery Question", mainPopup, function () { + const recoveryQuestionPopup = createPopup("Set Recovery Question"); + const recoveryQuestionForm = recoveryQuestionPopup[0].appendChild(document.createElement("form")); // Cuz "" didn't work. + recoveryQuestionForm.innerHTML = "

"; + newRecoveryQuestion.focus(); // Cuz "autofocus" didn't work. + recoveryQuestionForm.onsubmit = function (event) { + const url = `/api/v1/users/${userId}`; + const data = { + credentials: { + recovery_question: { + question: newRecoveryQuestion.value, + answer: newRecoveryAnswer.value + } + } + }; + postJSON({url, data}) + .then(() => recoveryQuestionPopup.html("Recovery question set.")) + .fail(jqXHR => recoveryQuestionPopup.html(e(jqXHR.responseJSON.errorCauses[0].errorSummary))); + event.preventDefault(); + }; + }); } function directoryGroups() {