invite update

This commit is contained in:
MathMan05
2025-11-14 18:52:34 -06:00
parent d61eb51461
commit afff118d54
3 changed files with 40 additions and 6 deletions
+11 -3
View File
@@ -78,9 +78,17 @@ import {getBulkUsers, Specialuser} from "./utils/utils.js";
async function showAccounts() {
console.log("showing!");
const user = await new AccountSwitcher((user) => {
return !!(well && user.serverurls.wellknown.includes(well));
}).show();
const user = await new AccountSwitcher(
(user) => {
return !!(well && user.serverurls.wellknown.includes(well));
},
{
loginText: () => I18n.login.login(),
createOpt: true,
loginurl: "/login?" + new URLSearchParams([["goback", window.location.href]]),
registerurl: "/register?" + new URLSearchParams([["goback", window.location.href]]),
},
).show();
fetch(`${urls!.api}/invites/${code}`, {
method: "POST",
headers: {
+28 -3
View File
@@ -16,14 +16,30 @@ export class AccountSwitcher {
canCreate: boolean;
canLogOut: boolean;
canHide: boolean;
createOpt: boolean;
loginText: () => string;
loginurl: string;
registerurl: string;
constructor(
filter: AccountSwitcher["filter"] = () => true,
{canCreate = true, canLogOut = true, canHide = true} = {},
{
canCreate = true,
createOpt = false,
canLogOut = true,
canHide = true,
loginurl = "/login",
registerurl = "/register",
loginText = () => I18n.switchAccounts(),
} = {},
) {
this.filter = filter;
this.canCreate = canCreate;
this.canLogOut = canLogOut;
this.canHide = canHide;
this.loginText = loginText;
this.createOpt = createOpt;
this.loginurl = loginurl;
this.registerurl = registerurl;
}
async show(): Promise<Specialuser> {
const table = document.createElement("div");
@@ -79,9 +95,18 @@ export class AccountSwitcher {
if (this.canCreate) {
const switchAccountDiv = document.createElement("div");
switchAccountDiv.classList.add("switchtable");
switchAccountDiv.textContent = I18n.switchAccounts();
switchAccountDiv.textContent = this.loginText();
switchAccountDiv.addEventListener("click", () => {
window.location.href = "/login";
window.location.href = this.loginurl;
});
table.append(switchAccountDiv);
}
if (this.createOpt) {
const switchAccountDiv = document.createElement("div");
switchAccountDiv.classList.add("switchtable");
switchAccountDiv.textContent = I18n.createAccount();
switchAccountDiv.addEventListener("click", () => {
window.location.href = this.registerurl;
});
table.append(switchAccountDiv);
}
+1
View File
@@ -414,6 +414,7 @@
"DISCOVERABLE": "Discovery"
},
"welcomeMessages": "Welcome $1! Nice to see ya!\nHello, nice to meet you $1!\nWelcome, hope you brought pizza $1!",
"createAccount":"Create Account",
"role": {
"displaySettings": "Display settings",
"name": "Role name:",