This commit is contained in:
@@ -51,14 +51,16 @@ function persistCurrentUser() {
|
||||
}
|
||||
}
|
||||
|
||||
let users = readStorageJson("eagleUsers", []);
|
||||
export let users = readStorageJson("eagleUsers", []);
|
||||
if (!Array.isArray(users)) {
|
||||
users = [];
|
||||
}
|
||||
users = users.map(normalizeUser).filter(Boolean);
|
||||
|
||||
const rawCurrentUser = readStorageJson("currentUser", null);
|
||||
var currentUser: User | null = rawCurrentUser ? normalizeUser(rawCurrentUser) : null;
|
||||
|
||||
export var currentUser: User | null = rawCurrentUser ? normalizeUser(rawCurrentUser) : null;
|
||||
|
||||
if (currentUser && currentUser.email) {
|
||||
const currentEmail = currentUser.email;
|
||||
const storedMatch = users.find((user: { email: string; }) => {
|
||||
@@ -84,7 +86,7 @@ function getInputValue(id: string): string {
|
||||
return el?.value.trim() ?? "";
|
||||
}
|
||||
|
||||
async function registerUser() {
|
||||
export async function registerUser() {
|
||||
const firstName = getInputValue("reg-firstname");
|
||||
const lastName = getInputValue("reg-lastname");
|
||||
const email = getInputValue("reg-email").toLowerCase();
|
||||
@@ -129,7 +131,7 @@ const password = document.querySelector<HTMLInputElement>("#reg-password")?.valu
|
||||
openAccountDashboard();
|
||||
}
|
||||
|
||||
async function loginUser() {
|
||||
export async function loginUser() {
|
||||
const email = (document.querySelector<HTMLInputElement>("#login-email")?.value.trim() || "").toLowerCase();
|
||||
const password = document.querySelector<HTMLInputElement>("#login-password")?.value || "";
|
||||
const hashedPassword = await hashMessage(password);
|
||||
@@ -148,7 +150,7 @@ async function loginUser() {
|
||||
openAccountDashboard();
|
||||
}
|
||||
|
||||
function openAccountDashboard() {
|
||||
export function openAccountDashboard() {
|
||||
const accountView = document.getElementById("account-view");
|
||||
if (!accountView) {
|
||||
return;
|
||||
@@ -464,3 +466,4 @@ function logoutUser() {
|
||||
persistCurrentUser();
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user