From 096bd5976b3c2661350f8997e6f4aeba1ed13ad3 Mon Sep 17 00:00:00 2001 From: adminsopel Date: Fri, 1 May 2026 10:13:50 +0200 Subject: [PATCH] Fix login flow after rollback --- manifest.toml | 3 +- scripts/backup | 3 +- scripts/install | 3 +- scripts/remove | 3 +- scripts/restore | 3 +- scripts/upgrade | 19 +- web/app.js | 93 +------ web/index.html | 12 +- web/styles.css | 642 +----------------------------------------------- 9 files changed, 22 insertions(+), 759 deletions(-) diff --git a/manifest.toml b/manifest.toml index a396646..51f5b35 100644 --- a/manifest.toml +++ b/manifest.toml @@ -1,10 +1,9 @@ packaging_format = 2 id = "albumik" name = "Albumik" -logo = "assets/albumik-logo.png" description.en = "Lightweight private photo album with folder permissions and guest uploads" description.pl = "Lekki prywatny album zdjęć z katalogami, gośćmi i akceptacją zdjęć" -version = "0.1.2~ynh1" +version = "0.1.0~ynh1" maintainers = ["Filip"] [upstream] diff --git a/scripts/backup b/scripts/backup index 78fa71e..e21b91a 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,6 @@ #!/bin/bash set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -source "$SCRIPT_DIR/_common.sh" +source ./_common.sh mkdir -p "$YNH_BACKUP_DIR" tar -C / -czf "$YNH_BACKUP_DIR/albumik-data.tar.gz" "${data_dir#/}" "${config_dir#/}" "${install_dir#/}" 2>/dev/null || true diff --git a/scripts/install b/scripts/install index 552a9b4..3f36b67 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,6 @@ #!/bin/bash set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -source "$SCRIPT_DIR/_common.sh" +source ./_common.sh # YunoHost install args # packaging v2 passes these variables to scripts. diff --git a/scripts/remove b/scripts/remove index d2ccce4..695509b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,6 @@ #!/bin/bash set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -source "$SCRIPT_DIR/_common.sh" +source ./_common.sh domain=$(yunohost app setting "$app" domain 2>/dev/null || echo "") diff --git a/scripts/restore b/scripts/restore index c686411..ca9f57f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,6 @@ #!/bin/bash set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -source "$SCRIPT_DIR/_common.sh" +source ./_common.sh if [ -f "$YNH_BACKUP_DIR/albumik-data.tar.gz" ]; then tar -C / -xzf "$YNH_BACKUP_DIR/albumik-data.tar.gz" diff --git a/scripts/upgrade b/scripts/upgrade index b489783..26043ba 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,22 +1,13 @@ #!/bin/bash set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -source "$SCRIPT_DIR/_common.sh" - -app="${YNH_APP_INSTANCE_NAME:-albumik}" +source ./_common.sh +systemctl stop "$app" 2>/dev/null || true mkdir -p "$install_dir" - rm -rf "$install_dir/backend" "$install_dir/web" "$install_dir/doc" - -cp -a "$YNH_APP_BASEDIR/backend" "$YNH_APP_BASEDIR/web" "$YNH_APP_BASEDIR/doc" "$install_dir"/ - +cp -a backend web doc "$install_dir"/ chown -R "$app:$app" "$install_dir" - systemctl daemon-reload -systemctl restart "$app" - -nginx -t -systemctl reload nginx - +systemctl start "$app" +systemctl reload nginx || true echo "Albumik upgraded" diff --git a/web/app.js b/web/app.js index 8826d24..549d2e8 100644 --- a/web/app.js +++ b/web/app.js @@ -155,7 +155,7 @@ $('#loginForm').addEventListener('submit', async e=>{ e.preventDefault(); $('#loginError').textContent = ''; const fd = new FormData(e.currentTarget); - try { await api('/api/login', {method:'POST', body: JSON.stringify(Object.fromEntries(fd))}); await init(); } + try { await api('/api/login', {method:'POST', body: JSON.stringify(Object.fromEntries(fd))}); window.location.href = '/'; return; } catch(err){ $('#loginError').textContent = err.message; } }); $('#logoutBtn').addEventListener('click', async()=>{ await api('/api/logout',{method:'POST',body:'{}'}); location.reload(); }); @@ -221,94 +221,3 @@ $('#rejectPhotoBtn').addEventListener('click', async()=>{ }); init(); - -function renderAccountView() { - const main = document.querySelector("#content") || document.querySelector("main") || document.querySelector(".main"); - if (!main) return; - - const user = state.user || {}; - main.innerHTML = ` -
-

Moje konto

-

Zmień swoje hasło i sprawdź informacje o koncie.

-
- -
-

Dane konta

-
Login${escapeHtml(user.username || '')}
-
Nazwa${escapeHtml(user.display_name || '')}
-
Rola${escapeHtml(user.role || '')}
-
- -
-

Zmiana hasła

-
-
- - -
-
- - -
-
- - -
-
- -
-
- `; - - document.querySelector("#changePasswordForm")?.addEventListener("submit", async (e) => { - e.preventDefault(); - const fd = new FormData(e.currentTarget); - const current_password = fd.get("current_password"); - const new_password = fd.get("new_password"); - const repeat_password = fd.get("repeat_password"); - const err = document.querySelector("#changePasswordError"); - - if (new_password !== repeat_password) { - err.textContent = "Nowe hasła nie są takie same."; - return; - } - - try { - const res = await api("/api/me/password", { - method: "POST", - body: JSON.stringify({ current_password, new_password }) - }); - - if (!res.ok) { - err.textContent = res.error || "Nie udało się zmienić hasła."; - return; - } - - err.style.color = "#16a34a"; - err.textContent = "Hasło zostało zmienione."; - e.currentTarget.reset(); - } catch (ex) { - err.textContent = "Błąd połączenia z serwerem."; - } - }); -} - -function escapeHtml(value) { - return String(value ?? "") - .replaceAll("&", "&") - .replaceAll("<", "<") - .replaceAll(">", ">") - .replaceAll('"', """) - .replaceAll("'", "'"); -} - -document.addEventListener("click", (e) => { - const btn = e.target.closest("[data-view='account']"); - if (!btn) return; - e.preventDefault(); - state.currentView = "account"; - document.querySelectorAll(".nav-btn").forEach(b => b.classList.remove("active")); - btn.classList.add("active"); - renderAccountView(); -}); diff --git a/web/index.html b/web/index.html index 81926f7..194c561 100644 --- a/web/index.html +++ b/web/index.html @@ -4,15 +4,15 @@ Albumik - +