implement frontend for user expiry/duration

this will add an optional validity period to users, where their account
will be disabled (or deleted) a specified amount of time after they
created it.
This commit is contained in:
Harvey Tindall
2021-02-28 00:44:28 +00:00
parent 3635b6a367
commit 2934832a98
14 changed files with 269 additions and 65 deletions
+18
View File
@@ -10,6 +10,11 @@ interface formWindow extends Window {
messages: { [key: string]: string };
confirmation: boolean;
confirmationModal: Modal
userDurationEnabled: boolean;
userDurationDays: number;
userDurationHours: number;
userDurationMinutes: number;
userDurationMessage: string;
}
interface pwValString {
@@ -34,6 +39,19 @@ if (window.confirmation) {
}
declare var window: formWindow;
if (window.userDurationEnabled) {
const messageEl = document.getElementById("user-duration-message") as HTMLElement;
const calculateTime = () => {
let time = new Date()
time.setDate(time.getDate() + window.userDurationDays);
time.setHours(time.getHours() + window.userDurationHours);
time.setMinutes(time.getMinutes() + window.userDurationMinutes);
messageEl.textContent = window.userDurationMessage.replace("{date}", time.toDateString() + " " + time.toLocaleTimeString());
setTimeout(calculateTime, 1000);
};
calculateTime();
}
var defaultPwValStrings: pwValStrings = {
length: {
singular: "Must have at least {n} character",