ngx-xtroedge-cms 1.3.3 → 1.3.5

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
@@ -1776,8 +1776,8 @@ var XtroedgeCMS = class _XtroedgeCMS {
1776
1776
  <div class="lcms-login-title">Builder Login</div>
1777
1777
  <div class="lcms-login-sub">Sign in to access edit mode</div>
1778
1778
  <div class="lcms-login-field">
1779
- <label class="lcms-login-label">Email or Username</label>
1780
- <input class="lcms-login-input" id="lcms-login-email" type="text" placeholder="Enter your email or username" autocomplete="username" />
1779
+ <label class="lcms-login-label">Username</label>
1780
+ <input class="lcms-login-input" id="lcms-login-email" type="text" placeholder="Enter your username" autocomplete="username" />
1781
1781
  </div>
1782
1782
  <div class="lcms-login-field">
1783
1783
  <label class="lcms-login-label">Password</label>
@@ -1807,7 +1807,7 @@ var XtroedgeCMS = class _XtroedgeCMS {
1807
1807
  const btn = document.getElementById("lcms-login-btn");
1808
1808
  const errorEl = document.getElementById("lcms-login-error");
1809
1809
  if (!email || !password) {
1810
- errorEl.textContent = "Please enter your email/username and password.";
1810
+ errorEl.textContent = "Please enter your username and password.";
1811
1811
  errorEl.classList.add("visible");
1812
1812
  return;
1813
1813
  }
@@ -1819,12 +1819,19 @@ var XtroedgeCMS = class _XtroedgeCMS {
1819
1819
  const res = await fetch(loginUrl, {
1820
1820
  method: "POST",
1821
1821
  headers: { "Content-Type": "application/json" },
1822
- body: JSON.stringify({ email, password })
1822
+ body: JSON.stringify({ username: email, password })
1823
1823
  });
1824
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
1825
- const data = await res.json();
1824
+ let data = null;
1825
+ try {
1826
+ data = await res.json();
1827
+ } catch {
1828
+ }
1829
+ if (!res.ok) {
1830
+ const apiMsg = data?.message || data?.error || null;
1831
+ throw new Error(apiMsg || `HTTP ${res.status}`);
1832
+ }
1826
1833
  const token = data?.token || data?.authToken || data?.auth_token || data?.data?.token;
1827
- if (!token) throw new Error("No token in response");
1834
+ if (!token) throw new Error("Login successful but no token returned.");
1828
1835
  localStorage.setItem("builder_token", token);
1829
1836
  this.hideLoginModal();
1830
1837
  this.editMode = true;
@@ -1833,10 +1840,10 @@ var XtroedgeCMS = class _XtroedgeCMS {
1833
1840
  this.applyEditMode(true);
1834
1841
  this.updateUI();
1835
1842
  this.loadPageContent("draft");
1836
- } catch {
1843
+ } catch (err) {
1837
1844
  btn.disabled = false;
1838
1845
  btn.textContent = "Sign In";
1839
- errorEl.textContent = "Invalid credentials. Please try again.";
1846
+ errorEl.textContent = err?.message || "Login failed. Please try again.";
1840
1847
  errorEl.classList.add("visible");
1841
1848
  }
1842
1849
  }