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:
+18
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user