ngx-xtroedge-cms 1.3.4 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1668,6 +1668,9 @@ var XtroedgeCMS = class _XtroedgeCMS {
1668
1668
  }
1669
1669
  switchLang(lang) {
1670
1670
  this.currentLang = lang;
1671
+ document.documentElement.setAttribute("lang", lang);
1672
+ localStorage.setItem("selectedLanguage", lang);
1673
+ window.dispatchEvent(new CustomEvent("cms:langChanged", { detail: { lang } }));
1671
1674
  this.updateElementTexts();
1672
1675
  this.buildLangButtons();
1673
1676
  this.updateUI();
@@ -1821,10 +1824,17 @@ var XtroedgeCMS = class _XtroedgeCMS {
1821
1824
  headers: { "Content-Type": "application/json" },
1822
1825
  body: JSON.stringify({ username: email, password })
1823
1826
  });
1824
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
1825
- const data = await res.json();
1827
+ let data = null;
1828
+ try {
1829
+ data = await res.json();
1830
+ } catch {
1831
+ }
1832
+ if (!res.ok) {
1833
+ const apiMsg = data?.message || data?.error || null;
1834
+ throw new Error(apiMsg || `HTTP ${res.status}`);
1835
+ }
1826
1836
  const token = data?.token || data?.authToken || data?.auth_token || data?.data?.token;
1827
- if (!token) throw new Error("No token in response");
1837
+ if (!token) throw new Error("Login successful but no token returned.");
1828
1838
  localStorage.setItem("builder_token", token);
1829
1839
  this.hideLoginModal();
1830
1840
  this.editMode = true;
@@ -1833,10 +1843,10 @@ var XtroedgeCMS = class _XtroedgeCMS {
1833
1843
  this.applyEditMode(true);
1834
1844
  this.updateUI();
1835
1845
  this.loadPageContent("draft");
1836
- } catch {
1846
+ } catch (err) {
1837
1847
  btn.disabled = false;
1838
1848
  btn.textContent = "Sign In";
1839
- errorEl.textContent = "Invalid credentials. Please try again.";
1849
+ errorEl.textContent = err?.message || "Login failed. Please try again.";
1840
1850
  errorEl.classList.add("visible");
1841
1851
  }
1842
1852
  }