@vue-skuilder/common-ui 0.1.13-7 → 0.1.13-8
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/common-ui.es.js +53 -14
- package/dist/common-ui.es.js.map +1 -1
- package/dist/common-ui.umd.js +1 -1
- package/dist/common-ui.umd.js.map +1 -1
- package/dist/components/auth/index.d.ts +1 -1
- package/dist/components/auth/index.d.ts.map +1 -1
- package/dist/stores/useAuthStore.d.ts +2 -2
- package/dist/stores/useAuthStore.d.ts.map +1 -1
- package/dist/stores/useConfigStore.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/auth/index.ts +2 -0
- package/src/stores/useAuthStore.ts +6 -2
- package/src/stores/useConfigStore.ts +27 -13
package/dist/common-ui.es.js
CHANGED
|
@@ -15821,11 +15821,14 @@ const useAuthStore = () => {
|
|
|
15821
15821
|
async init() {
|
|
15822
15822
|
try {
|
|
15823
15823
|
this._user = getDataLayer().getUserDB();
|
|
15824
|
-
this.loginAndRegistration.loggedIn = this._user.isLoggedIn();
|
|
15824
|
+
this.loginAndRegistration.loggedIn = this._user ? this._user.isLoggedIn() : false;
|
|
15825
15825
|
this.onLoadComplete = true;
|
|
15826
15826
|
this.loginAndRegistration.init = true;
|
|
15827
15827
|
} catch (e) {
|
|
15828
15828
|
console.error("Failed to initialize auth store:", e);
|
|
15829
|
+
this.loginAndRegistration.loggedIn = false;
|
|
15830
|
+
this.onLoadComplete = true;
|
|
15831
|
+
this.loginAndRegistration.init = true;
|
|
15829
15832
|
}
|
|
15830
15833
|
},
|
|
15831
15834
|
setLoginDialog(open) {
|
|
@@ -15886,29 +15889,43 @@ const useConfigStore = () => {
|
|
|
15886
15889
|
async updateDarkMode(darkMode) {
|
|
15887
15890
|
this.config.darkMode = darkMode;
|
|
15888
15891
|
const user = await getCurrentUser();
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
+
if (user) {
|
|
15893
|
+
await user.setConfig({
|
|
15894
|
+
darkMode
|
|
15895
|
+
});
|
|
15896
|
+
}
|
|
15892
15897
|
},
|
|
15893
15898
|
async updateLikesConfetti(likesConfetti) {
|
|
15894
15899
|
this.config.likesConfetti = likesConfetti;
|
|
15895
15900
|
const user = await getCurrentUser();
|
|
15896
|
-
|
|
15897
|
-
|
|
15898
|
-
|
|
15901
|
+
if (user) {
|
|
15902
|
+
await user.setConfig({
|
|
15903
|
+
likesConfetti
|
|
15904
|
+
});
|
|
15905
|
+
}
|
|
15899
15906
|
},
|
|
15900
15907
|
async updateSessionTimeLimit(sessionTimeLimit) {
|
|
15901
15908
|
this.config.sessionTimeLimit = sessionTimeLimit;
|
|
15902
15909
|
const user = await getCurrentUser();
|
|
15903
|
-
|
|
15904
|
-
|
|
15905
|
-
|
|
15910
|
+
if (user) {
|
|
15911
|
+
await user.setConfig({
|
|
15912
|
+
sessionTimeLimit
|
|
15913
|
+
});
|
|
15914
|
+
}
|
|
15906
15915
|
},
|
|
15907
15916
|
async hydrate() {
|
|
15908
|
-
|
|
15909
|
-
|
|
15910
|
-
|
|
15911
|
-
|
|
15917
|
+
try {
|
|
15918
|
+
const user = await getCurrentUser();
|
|
15919
|
+
if (user) {
|
|
15920
|
+
const cfg = await user.getConfig();
|
|
15921
|
+
console.log(`user config: ${JSON.stringify(cfg)}`);
|
|
15922
|
+
this.updateConfig(cfg);
|
|
15923
|
+
} else {
|
|
15924
|
+
console.log("No user logged in, using default config");
|
|
15925
|
+
}
|
|
15926
|
+
} catch (e) {
|
|
15927
|
+
console.warn("Failed to hydrate config store, using defaults:", e);
|
|
15928
|
+
}
|
|
15912
15929
|
},
|
|
15913
15930
|
async init() {
|
|
15914
15931
|
await this.hydrate();
|
|
@@ -16549,6 +16566,27 @@ async function verifyEmail(token2) {
|
|
|
16549
16566
|
};
|
|
16550
16567
|
}
|
|
16551
16568
|
}
|
|
16569
|
+
async function getUserStatus() {
|
|
16570
|
+
try {
|
|
16571
|
+
const response = await fetch("/auth/status", {
|
|
16572
|
+
method: "GET",
|
|
16573
|
+
headers: { "Content-Type": "application/json" },
|
|
16574
|
+
credentials: "include"
|
|
16575
|
+
});
|
|
16576
|
+
if (!response.ok) {
|
|
16577
|
+
return {
|
|
16578
|
+
ok: false,
|
|
16579
|
+
error: `HTTP ${response.status}: ${response.statusText}`
|
|
16580
|
+
};
|
|
16581
|
+
}
|
|
16582
|
+
return await response.json();
|
|
16583
|
+
} catch (error) {
|
|
16584
|
+
return {
|
|
16585
|
+
ok: false,
|
|
16586
|
+
error: error instanceof Error ? error.message : "Network error"
|
|
16587
|
+
};
|
|
16588
|
+
}
|
|
16589
|
+
}
|
|
16552
16590
|
async function requestPasswordReset(email, origin) {
|
|
16553
16591
|
try {
|
|
16554
16592
|
const body = { email };
|
|
@@ -18716,6 +18754,7 @@ export {
|
|
|
18716
18754
|
alertUser,
|
|
18717
18755
|
containsComponent,
|
|
18718
18756
|
getCurrentUser,
|
|
18757
|
+
getUserStatus,
|
|
18719
18758
|
isComponent,
|
|
18720
18759
|
isDefineComponent,
|
|
18721
18760
|
isPasswordValid,
|