mirror of
https://github.com/MathMan05/Fermi.git
synced 2026-04-27 08:35:41 +00:00
invite update
This commit is contained in:
+11
-3
@@ -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: {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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:",
|
||||
|
||||
Reference in New Issue
Block a user