Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'Expire Password' and 'Set Recovery Question' functions #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions rockstar/rockstar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<form>" didn't work.
expirePasswordForm.innerHTML = "<div>New password will be required at next login</div><br><button class='link-button'>Expire Password</button>";
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 "<form>" didn't work.
recoveryQuestionForm.innerHTML = "<input id=newRecoveryQuestion placeholder='New Question'><br><input id=newRecoveryAnswer placeholder='New Answer'><br><button class='link-button'>Set</button>";
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() {
Expand Down