From 9dfa53967e0ddece4a0bdd188ca490900bd16a0d Mon Sep 17 00:00:00 2001 From: Daniel Kuchenski <29745101+dkuchenski@users.noreply.github.com> Date: Wed, 22 Jul 2020 21:02:21 -0700 Subject: [PATCH] Added 'Expire Password' and 'Set Recovery Question' functions for Okta users --- rockstar/rockstar.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) 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() {