2021-01-05 18:16:23 +00:00
|
|
|
import { Modal } from "./modules/modal.js";
|
2021-05-07 13:32:51 +00:00
|
|
|
import { notificationBox, whichAnimationEvent } from "./modules/common.js";
|
2023-06-19 10:58:09 +00:00
|
|
|
import { _get, _post, toggleLoader, addLoader, removeLoader, toDateString } from "./modules/common.js";
|
2021-01-12 23:43:44 +00:00
|
|
|
import { loadLangSelector } from "./modules/lang.js";
|
2023-06-22 19:54:52 +00:00
|
|
|
import { Validator, ValidatorConf, ValidatorRespDTO } from "./modules/validator.js";
|
2023-06-20 11:57:52 +00:00
|
|
|
import { Discord, Telegram, Matrix, ServiceConfiguration, MatrixConfiguration } from "./modules/account-linking.js";
|
2020-10-22 16:50:40 +00:00
|
|
|
|
|
|
|
interface formWindow extends Window {
|
2020-11-04 20:46:06 +00:00
|
|
|
invalidPassword: string;
|
2021-05-07 00:08:12 +00:00
|
|
|
successModal: Modal;
|
|
|
|
telegramModal: Modal;
|
2021-05-21 20:35:25 +00:00
|
|
|
discordModal: Modal;
|
2021-05-29 16:43:11 +00:00
|
|
|
matrixModal: Modal;
|
2023-02-02 10:34:22 +00:00
|
|
|
confirmationModal: Modal;
|
|
|
|
redirectToJellyfin: boolean;
|
2021-01-14 14:22:20 +00:00
|
|
|
code: string;
|
2021-01-25 18:01:18 +00:00
|
|
|
messages: { [key: string]: string };
|
2021-01-30 19:19:12 +00:00
|
|
|
confirmation: boolean;
|
2021-05-07 00:08:12 +00:00
|
|
|
telegramRequired: boolean;
|
|
|
|
telegramPIN: string;
|
2021-05-21 20:35:25 +00:00
|
|
|
discordRequired: boolean;
|
|
|
|
discordPIN: string;
|
|
|
|
discordStartCommand: string;
|
2021-05-23 18:50:03 +00:00
|
|
|
discordInviteLink: boolean;
|
|
|
|
discordServerName: string;
|
2021-05-29 16:43:11 +00:00
|
|
|
matrixRequired: boolean;
|
|
|
|
matrixUserID: string;
|
2021-02-28 15:41:06 +00:00
|
|
|
userExpiryEnabled: boolean;
|
2021-04-08 19:43:01 +00:00
|
|
|
userExpiryMonths: number;
|
2021-02-28 15:41:06 +00:00
|
|
|
userExpiryDays: number;
|
|
|
|
userExpiryHours: number;
|
|
|
|
userExpiryMinutes: number;
|
|
|
|
userExpiryMessage: string;
|
2021-12-20 18:44:31 +00:00
|
|
|
emailRequired: boolean;
|
2022-01-10 01:55:48 +00:00
|
|
|
captcha: boolean;
|
2023-06-15 16:11:27 +00:00
|
|
|
reCAPTCHA: boolean;
|
|
|
|
reCAPTCHASiteKey: string;
|
2023-06-22 09:11:56 +00:00
|
|
|
userPageEnabled: boolean;
|
2023-06-22 20:57:19 +00:00
|
|
|
userPageAddress: string;
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 23:43:44 +00:00
|
|
|
loadLangSelector("form");
|
2021-01-11 19:17:43 +00:00
|
|
|
|
2021-05-07 00:08:12 +00:00
|
|
|
window.notifications = new notificationBox(document.getElementById("notification-box") as HTMLDivElement);
|
|
|
|
|
2021-05-07 13:32:51 +00:00
|
|
|
window.animationEvent = whichAnimationEvent();
|
|
|
|
|
2021-05-07 00:08:12 +00:00
|
|
|
window.successModal = new Modal(document.getElementById("modal-success"), true);
|
|
|
|
|
2021-12-20 18:44:31 +00:00
|
|
|
|
2021-05-07 13:32:51 +00:00
|
|
|
var telegramVerified = false;
|
2021-05-07 00:08:12 +00:00
|
|
|
if (window.telegramEnabled) {
|
|
|
|
window.telegramModal = new Modal(document.getElementById("modal-telegram"), window.telegramRequired);
|
2021-05-07 13:32:51 +00:00
|
|
|
const telegramButton = document.getElementById("link-telegram") as HTMLSpanElement;
|
2023-06-19 21:11:35 +00:00
|
|
|
|
|
|
|
const telegramConf: ServiceConfiguration = {
|
|
|
|
modal: window.telegramModal as Modal,
|
|
|
|
pin: window.telegramPIN,
|
|
|
|
pinURL: "",
|
|
|
|
verifiedURL: "/invite/" + window.code + "/telegram/verified/",
|
2023-06-20 11:57:52 +00:00
|
|
|
invalidCodeError: window.messages["errorInvalidPIN"],
|
2023-06-19 21:11:35 +00:00
|
|
|
accountLinkedError: window.messages["errorAccountLinked"],
|
|
|
|
successError: window.messages["verified"],
|
|
|
|
successFunc: (modalClosed: boolean) => {
|
|
|
|
if (modalClosed) return;
|
|
|
|
telegramVerified = true;
|
|
|
|
telegramButton.classList.add("unfocused");
|
|
|
|
document.getElementById("contact-via").classList.remove("unfocused");
|
|
|
|
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
2023-06-23 11:30:52 +00:00
|
|
|
const checkbox = document.getElementById("contact-via-telegram") as HTMLInputElement;
|
|
|
|
checkbox.parentElement.classList.remove("unfocused");
|
|
|
|
checkbox.checked = true;
|
2023-06-22 17:31:16 +00:00
|
|
|
validator.validate();
|
2021-05-07 17:20:35 +00:00
|
|
|
}
|
2021-05-07 00:08:12 +00:00
|
|
|
};
|
2023-06-19 21:11:35 +00:00
|
|
|
|
|
|
|
const telegram = new Telegram(telegramConf);
|
|
|
|
|
|
|
|
telegramButton.onclick = () => { telegram.onclick(); };
|
2021-05-07 00:08:12 +00:00
|
|
|
}
|
|
|
|
|
2021-05-21 20:35:25 +00:00
|
|
|
var discordVerified = false;
|
|
|
|
if (window.discordEnabled) {
|
|
|
|
window.discordModal = new Modal(document.getElementById("modal-discord"), window.discordRequired);
|
|
|
|
const discordButton = document.getElementById("link-discord") as HTMLSpanElement;
|
2023-06-19 10:58:09 +00:00
|
|
|
|
2023-06-19 21:11:35 +00:00
|
|
|
const discordConf: ServiceConfiguration = {
|
2023-06-19 10:58:09 +00:00
|
|
|
modal: window.discordModal as Modal,
|
|
|
|
pin: window.discordPIN,
|
|
|
|
inviteURL: window.discordInviteLink ? ("/invite/" + window.code + "/discord/invite") : "",
|
|
|
|
pinURL: "",
|
|
|
|
verifiedURL: "/invite/" + window.code + "/discord/verified/",
|
2023-06-20 11:57:52 +00:00
|
|
|
invalidCodeError: window.messages["errorInvalidPIN"],
|
2023-06-19 10:58:09 +00:00
|
|
|
accountLinkedError: window.messages["errorAccountLinked"],
|
|
|
|
successError: window.messages["verified"],
|
|
|
|
successFunc: (modalClosed: boolean) => {
|
2023-06-19 21:11:35 +00:00
|
|
|
if (modalClosed) return;
|
|
|
|
discordVerified = true;
|
|
|
|
discordButton.classList.add("unfocused");
|
|
|
|
document.getElementById("contact-via").classList.remove("unfocused");
|
|
|
|
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
2023-06-23 11:30:52 +00:00
|
|
|
const checkbox = document.getElementById("contact-via-discord") as HTMLInputElement;
|
|
|
|
checkbox.parentElement.classList.remove("unfocused")
|
|
|
|
checkbox.checked = true;
|
2023-06-22 17:31:16 +00:00
|
|
|
validator.validate();
|
2021-05-21 20:35:25 +00:00
|
|
|
}
|
|
|
|
};
|
2023-06-19 10:58:09 +00:00
|
|
|
|
|
|
|
const discord = new Discord(discordConf);
|
|
|
|
|
2023-06-19 21:11:35 +00:00
|
|
|
discordButton.onclick = () => { discord.onclick(); };
|
2021-05-21 20:35:25 +00:00
|
|
|
}
|
|
|
|
|
2021-05-29 16:43:11 +00:00
|
|
|
var matrixVerified = false;
|
|
|
|
var matrixPIN = "";
|
|
|
|
if (window.matrixEnabled) {
|
|
|
|
window.matrixModal = new Modal(document.getElementById("modal-matrix"), window.matrixRequired);
|
|
|
|
const matrixButton = document.getElementById("link-matrix") as HTMLSpanElement;
|
2023-06-20 11:57:52 +00:00
|
|
|
|
|
|
|
const matrixConf: MatrixConfiguration = {
|
|
|
|
modal: window.matrixModal as Modal,
|
|
|
|
sendMessageURL: "/invite/" + window.code + "/matrix/user",
|
|
|
|
verifiedURL: "/invite/" + window.code + "/matrix/verified/",
|
|
|
|
invalidCodeError: window.messages["errorInvalidPIN"],
|
|
|
|
accountLinkedError: window.messages["errorAccountLinked"],
|
2023-06-20 12:28:13 +00:00
|
|
|
unknownError: window.messages["errorUnknown"],
|
2023-06-20 11:57:52 +00:00
|
|
|
successError: window.messages["verified"],
|
|
|
|
successFunc: () => {
|
|
|
|
matrixVerified = true;
|
|
|
|
matrixPIN = matrix.pin;
|
|
|
|
matrixButton.classList.add("unfocused");
|
|
|
|
document.getElementById("contact-via").classList.remove("unfocused");
|
|
|
|
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
2023-06-23 11:30:52 +00:00
|
|
|
const checkbox = document.getElementById("contact-via-matrix") as HTMLInputElement;
|
|
|
|
checkbox.parentElement.classList.remove("unfocused");
|
|
|
|
checkbox.checked = true;
|
2023-06-22 17:31:16 +00:00
|
|
|
validator.validate();
|
2021-05-29 16:43:11 +00:00
|
|
|
}
|
|
|
|
};
|
2023-06-20 11:57:52 +00:00
|
|
|
|
|
|
|
const matrix = new Matrix(matrixConf);
|
|
|
|
|
|
|
|
matrixButton.onclick = () => { matrix.show(); };
|
2021-05-29 16:43:11 +00:00
|
|
|
}
|
|
|
|
|
2021-01-30 19:19:12 +00:00
|
|
|
if (window.confirmation) {
|
|
|
|
window.confirmationModal = new Modal(document.getElementById("modal-confirmation"), true);
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
declare var window: formWindow;
|
|
|
|
|
2021-02-28 15:41:06 +00:00
|
|
|
if (window.userExpiryEnabled) {
|
|
|
|
const messageEl = document.getElementById("user-expiry-message") as HTMLElement;
|
2021-02-28 00:44:28 +00:00
|
|
|
const calculateTime = () => {
|
|
|
|
let time = new Date()
|
2021-04-08 19:43:01 +00:00
|
|
|
time.setMonth(time.getMonth() + window.userExpiryMonths);
|
2021-02-28 15:41:06 +00:00
|
|
|
time.setDate(time.getDate() + window.userExpiryDays);
|
|
|
|
time.setHours(time.getHours() + window.userExpiryHours);
|
|
|
|
time.setMinutes(time.getMinutes() + window.userExpiryMinutes);
|
2021-04-07 14:17:15 +00:00
|
|
|
messageEl.textContent = window.userExpiryMessage.replace("{date}", toDateString(time));
|
2021-02-28 00:44:28 +00:00
|
|
|
setTimeout(calculateTime, 1000);
|
|
|
|
};
|
|
|
|
calculateTime();
|
|
|
|
}
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
const form = document.getElementById("form-create") as HTMLFormElement;
|
2023-06-22 17:31:16 +00:00
|
|
|
const submitInput = form.querySelector("input[type=submit]") as HTMLInputElement;
|
2021-01-05 18:16:23 +00:00
|
|
|
const submitSpan = form.querySelector("span.submit") as HTMLSpanElement;
|
2022-01-27 16:48:46 +00:00
|
|
|
const submitText = submitSpan.textContent;
|
2021-01-05 18:16:23 +00:00
|
|
|
let usernameField = document.getElementById("create-username") as HTMLInputElement;
|
|
|
|
const emailField = document.getElementById("create-email") as HTMLInputElement;
|
|
|
|
if (!window.usernameEnabled) { usernameField.parentElement.remove(); usernameField = emailField; }
|
|
|
|
const passwordField = document.getElementById("create-password") as HTMLInputElement;
|
|
|
|
const rePasswordField = document.getElementById("create-reenter-password") as HTMLInputElement;
|
|
|
|
|
2022-01-27 16:48:46 +00:00
|
|
|
let captchaVerified = false;
|
|
|
|
let captchaID = "";
|
|
|
|
let captchaInput = document.getElementById("captcha-input") as HTMLInputElement;
|
|
|
|
const captchaCheckbox = document.getElementById("captcha-success") as HTMLSpanElement;
|
|
|
|
let prevCaptcha = "";
|
|
|
|
|
2023-06-21 19:00:48 +00:00
|
|
|
let baseValidator = (oncomplete: (valid: boolean) => void): void => {
|
|
|
|
if (window.captcha && !window.reCAPTCHA && (captchaInput.value != prevCaptcha)) {
|
|
|
|
prevCaptcha = captchaInput.value;
|
|
|
|
_post("/captcha/verify/" + window.code + "/" + captchaID + "/" + captchaInput.value, null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status == 204) {
|
|
|
|
captchaCheckbox.innerHTML = `<i class="ri-check-line"></i>`;
|
|
|
|
captchaCheckbox.classList.add("~positive");
|
|
|
|
captchaCheckbox.classList.remove("~critical");
|
|
|
|
captchaVerified = true;
|
|
|
|
} else {
|
|
|
|
captchaCheckbox.innerHTML = `<i class="ri-close-line"></i>`;
|
|
|
|
captchaCheckbox.classList.add("~critical");
|
|
|
|
captchaCheckbox.classList.remove("~positive");
|
|
|
|
captchaVerified = false;
|
2022-01-27 16:48:46 +00:00
|
|
|
}
|
2023-06-21 19:00:48 +00:00
|
|
|
_baseValidator(oncomplete, captchaVerified);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
_baseValidator(oncomplete, captchaVerified);
|
2022-01-27 16:48:46 +00:00
|
|
|
}
|
2023-06-21 19:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function _baseValidator(oncomplete: (valid: boolean) => void, captchaValid: boolean): void {
|
2022-01-27 16:48:46 +00:00
|
|
|
if (window.emailRequired) {
|
|
|
|
if (!emailField.value.includes("@")) {
|
|
|
|
oncomplete(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (window.discordEnabled && window.discordRequired && !discordVerified) {
|
|
|
|
oncomplete(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (window.telegramEnabled && window.telegramRequired && !telegramVerified) {
|
|
|
|
oncomplete(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (window.matrixEnabled && window.matrixRequired && !matrixVerified) {
|
|
|
|
oncomplete(false);
|
|
|
|
return;
|
|
|
|
}
|
2023-06-21 19:00:48 +00:00
|
|
|
if (window.captcha && !window.reCAPTCHA && !captchaValid) {
|
|
|
|
oncomplete(false);
|
|
|
|
return;
|
2022-01-27 16:48:46 +00:00
|
|
|
}
|
2023-06-21 19:00:48 +00:00
|
|
|
oncomplete(true);
|
2021-12-20 18:44:31 +00:00
|
|
|
}
|
|
|
|
|
2023-06-15 16:11:27 +00:00
|
|
|
interface GreCAPTCHA {
|
|
|
|
render: (container: HTMLDivElement, parameters: {
|
|
|
|
sitekey?: string,
|
|
|
|
theme?: string,
|
|
|
|
size?: string,
|
|
|
|
tabindex?: number,
|
|
|
|
"callback"?: () => void,
|
|
|
|
"expired-callback"?: () => void,
|
|
|
|
"error-callback"?: () => void
|
|
|
|
}) => void;
|
|
|
|
getResponse: (opt_widget_id?: HTMLDivElement) => string;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare var grecaptcha: GreCAPTCHA
|
|
|
|
|
2023-06-22 17:31:16 +00:00
|
|
|
let validatorConf: ValidatorConf = {
|
|
|
|
passwordField: passwordField,
|
|
|
|
rePasswordField: rePasswordField,
|
|
|
|
submitInput: submitInput,
|
|
|
|
submitButton: submitSpan,
|
|
|
|
validatorFunc: baseValidator
|
|
|
|
};
|
|
|
|
|
|
|
|
let validator = new Validator(validatorConf);
|
|
|
|
var requirements = validator.requirements;
|
2022-01-27 16:48:46 +00:00
|
|
|
|
|
|
|
if (window.emailRequired) {
|
2023-06-22 17:31:16 +00:00
|
|
|
emailField.addEventListener("keyup", validator.validate)
|
2022-01-27 16:48:46 +00:00
|
|
|
}
|
2020-10-20 22:33:32 +00:00
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
interface sendDTO {
|
|
|
|
code: string;
|
|
|
|
email: string;
|
|
|
|
username: string;
|
|
|
|
password: string;
|
2021-05-07 13:32:51 +00:00
|
|
|
telegram_pin?: string;
|
|
|
|
telegram_contact?: boolean;
|
2021-05-21 20:35:25 +00:00
|
|
|
discord_pin?: string;
|
|
|
|
discord_contact?: boolean;
|
2021-05-29 16:43:11 +00:00
|
|
|
matrix_pin?: string;
|
|
|
|
matrix_contact?: boolean;
|
2022-01-13 20:39:51 +00:00
|
|
|
captcha_id?: string;
|
|
|
|
captcha_text?: string;
|
2022-01-10 01:55:48 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:14:16 +00:00
|
|
|
const genCaptcha = () => {
|
2022-01-10 01:55:48 +00:00
|
|
|
_get("/captcha/gen/"+window.code, null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status == 200) {
|
|
|
|
captchaID = req.response["id"];
|
|
|
|
document.getElementById("captcha-img").innerHTML = `
|
|
|
|
<img class="w-100" src="${window.location.toString().substring(0, window.location.toString().lastIndexOf("/invite"))}/captcha/img/${window.code}/${captchaID}"></img>
|
|
|
|
`;
|
2022-01-26 22:14:16 +00:00
|
|
|
captchaInput.value = "";
|
2022-01-10 01:55:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2022-01-26 22:14:16 +00:00
|
|
|
};
|
|
|
|
|
2023-06-15 16:11:27 +00:00
|
|
|
if (window.captcha && !window.reCAPTCHA) {
|
2022-01-26 22:14:16 +00:00
|
|
|
genCaptcha();
|
|
|
|
(document.getElementById("captcha-regen") as HTMLSpanElement).onclick = genCaptcha;
|
2023-06-22 17:31:16 +00:00
|
|
|
captchaInput.onkeyup = validator.validate;
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const create = (event: SubmitEvent) => {
|
|
|
|
event.preventDefault();
|
2023-06-15 16:11:27 +00:00
|
|
|
if (window.captcha && !window.reCAPTCHA && !captchaVerified) {
|
2022-01-10 01:55:48 +00:00
|
|
|
|
|
|
|
}
|
2023-06-23 11:30:52 +00:00
|
|
|
addLoader(submitSpan);
|
2021-01-05 18:16:23 +00:00
|
|
|
let send: sendDTO = {
|
2021-01-14 14:22:20 +00:00
|
|
|
code: window.code,
|
2021-01-05 18:16:23 +00:00
|
|
|
username: usernameField.value,
|
|
|
|
email: emailField.value,
|
|
|
|
password: passwordField.value
|
|
|
|
};
|
2021-05-07 13:32:51 +00:00
|
|
|
if (telegramVerified) {
|
|
|
|
send.telegram_pin = window.telegramPIN;
|
2023-06-23 11:30:52 +00:00
|
|
|
const checkbox = document.getElementById("contact-via-telegram") as HTMLInputElement;
|
|
|
|
if (checkbox.checked) {
|
2021-05-07 13:32:51 +00:00
|
|
|
send.telegram_contact = true;
|
|
|
|
}
|
|
|
|
}
|
2021-05-21 20:35:25 +00:00
|
|
|
if (discordVerified) {
|
|
|
|
send.discord_pin = window.discordPIN;
|
2023-06-23 11:30:52 +00:00
|
|
|
const checkbox = document.getElementById("contact-via-discord") as HTMLInputElement;
|
|
|
|
if (checkbox.checked) {
|
2021-05-21 20:35:25 +00:00
|
|
|
send.discord_contact = true;
|
|
|
|
}
|
|
|
|
}
|
2021-05-29 16:43:11 +00:00
|
|
|
if (matrixVerified) {
|
|
|
|
send.matrix_pin = matrixPIN;
|
2023-06-23 11:30:52 +00:00
|
|
|
const checkbox = document.getElementById("contact-via-matrix") as HTMLInputElement;
|
|
|
|
if (checkbox.checked) {
|
2021-05-29 16:43:11 +00:00
|
|
|
send.matrix_contact = true;
|
|
|
|
}
|
|
|
|
}
|
2022-01-10 01:55:48 +00:00
|
|
|
if (window.captcha) {
|
2023-06-15 16:11:27 +00:00
|
|
|
if (window.reCAPTCHA) {
|
|
|
|
send.captcha_text = grecaptcha.getResponse();
|
|
|
|
} else {
|
|
|
|
send.captcha_id = captchaID;
|
|
|
|
send.captcha_text = captchaInput.value;
|
|
|
|
}
|
2022-01-10 01:55:48 +00:00
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
_post("/newUser", send, (req: XMLHttpRequest) => {
|
2023-06-23 11:30:52 +00:00
|
|
|
if (req.readyState != 4) return;
|
|
|
|
removeLoader(submitSpan);
|
|
|
|
let vals = req.response as ValidatorRespDTO;
|
|
|
|
let valid = true;
|
|
|
|
for (let type in vals) {
|
|
|
|
if (requirements[type]) requirements[type].valid = vals[type];
|
|
|
|
if (!vals[type]) valid = false;
|
|
|
|
}
|
|
|
|
if (req.status == 200 && valid) {
|
|
|
|
if (window.redirectToJellyfin == true) {
|
|
|
|
const url = ((document.getElementById("modal-success") as HTMLDivElement).querySelector("a.submit") as HTMLAnchorElement).href;
|
|
|
|
window.location.href = url;
|
2021-01-05 18:16:23 +00:00
|
|
|
} else {
|
2023-06-23 11:30:52 +00:00
|
|
|
if (window.userPageEnabled) {
|
|
|
|
const userPageNoticeArea = document.getElementById("modal-success-user-page-area");
|
|
|
|
const link = `<a href="${window.userPageAddress}" target="_blank">${userPageNoticeArea.getAttribute("my-account-term")}</a>`;
|
|
|
|
userPageNoticeArea.innerHTML = userPageNoticeArea.textContent.replace("{myAccount}", link);
|
2022-01-27 16:48:46 +00:00
|
|
|
}
|
2023-06-23 11:30:52 +00:00
|
|
|
window.successModal.show();
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
2023-06-23 11:30:52 +00:00
|
|
|
} else if (req.status != 401 && req.status != 400){
|
|
|
|
submitSpan.classList.add("~critical");
|
|
|
|
submitSpan.classList.remove("~urge");
|
|
|
|
if (req.response["error"] as string) {
|
|
|
|
submitSpan.textContent = window.messages[req.response["error"]];
|
|
|
|
} else {
|
|
|
|
submitSpan.textContent = window.messages["errorPassword"];
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
submitSpan.classList.add("~urge");
|
|
|
|
submitSpan.classList.remove("~critical");
|
|
|
|
submitSpan.textContent = submitText;
|
|
|
|
}, 1000);
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
2021-01-25 18:01:18 +00:00
|
|
|
}, true, (req: XMLHttpRequest) => {
|
2023-06-23 11:30:52 +00:00
|
|
|
if (req.readyState != 4) return;
|
|
|
|
removeLoader(submitSpan);
|
|
|
|
if (req.status == 401 || req.status == 400) {
|
|
|
|
if (req.response["error"] as string) {
|
|
|
|
if (req.response["error"] == "confirmEmail") {
|
|
|
|
window.confirmationModal.show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (req.response["error"] in window.messages) {
|
|
|
|
submitSpan.textContent = window.messages[req.response["error"]];
|
|
|
|
} else {
|
|
|
|
submitSpan.textContent = req.response["error"];
|
2021-01-25 18:01:18 +00:00
|
|
|
}
|
2023-06-23 11:30:52 +00:00
|
|
|
setTimeout(() => { submitSpan.textContent = submitText; }, 1000);
|
2021-01-25 18:01:18 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-06-22 17:31:16 +00:00
|
|
|
validator.validate();
|
2022-01-27 16:48:46 +00:00
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
form.onsubmit = create;
|
2023-09-08 12:31:05 +00:00
|
|
|
|
|
|
|
const invitedByAside = document.getElementById("invite-from-user");
|
|
|
|
if (typeof(invitedByAside) != "undefined" && invitedByAside != null) {
|
|
|
|
invitedByAside.textContent = invitedByAside.textContent.replace("{user}", invitedByAside.getAttribute("data-from"));
|
|
|
|
}
|