@vue-skuilder/common-ui 0.1.13-4 → 0.1.13-7
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 -13
- 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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/services/authAPI.d.ts +12 -3
- package/dist/services/authAPI.d.ts.map +1 -1
- package/dist/utils/passwordValidation.d.ts +13 -0
- package/dist/utils/passwordValidation.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/SkMouseTrap.vue +1 -1
- package/src/components/auth/UserRegistration.vue +41 -11
- package/src/index.ts +5 -0
- package/src/services/authAPI.ts +40 -3
- package/src/utils/passwordValidation.ts +31 -0
package/dist/common-ui.es.js
CHANGED
|
@@ -4928,7 +4928,7 @@ function _sfc_render$p(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4928
4928
|
createVNode(_component_v_card, null, {
|
|
4929
4929
|
default: withCtx(() => [
|
|
4930
4930
|
createVNode(_component_v_toolbar, {
|
|
4931
|
-
color: "
|
|
4931
|
+
color: "secondary",
|
|
4932
4932
|
dark: "",
|
|
4933
4933
|
dense: ""
|
|
4934
4934
|
}, {
|
|
@@ -16498,9 +16498,9 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
16498
16498
|
}
|
|
16499
16499
|
});
|
|
16500
16500
|
const UserLogin = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-563b0048"]]);
|
|
16501
|
-
async function sendVerificationEmail(username, origin) {
|
|
16501
|
+
async function sendVerificationEmail(username, email, origin) {
|
|
16502
16502
|
try {
|
|
16503
|
-
const body = { username };
|
|
16503
|
+
const body = { username, email };
|
|
16504
16504
|
if (origin) {
|
|
16505
16505
|
body.origin = origin;
|
|
16506
16506
|
}
|
|
@@ -16511,6 +16511,8 @@ async function sendVerificationEmail(username, origin) {
|
|
|
16511
16511
|
body: JSON.stringify(body)
|
|
16512
16512
|
});
|
|
16513
16513
|
if (!response.ok) {
|
|
16514
|
+
const errorText = await response.text();
|
|
16515
|
+
console.error("Send verification email error:", errorText);
|
|
16514
16516
|
return {
|
|
16515
16517
|
ok: false,
|
|
16516
16518
|
error: `HTTP ${response.status}: ${response.statusText}`
|
|
@@ -16518,6 +16520,7 @@ async function sendVerificationEmail(username, origin) {
|
|
|
16518
16520
|
}
|
|
16519
16521
|
return await response.json();
|
|
16520
16522
|
} catch (error) {
|
|
16523
|
+
console.error("Send verification email fetch error:", error);
|
|
16521
16524
|
return {
|
|
16522
16525
|
ok: false,
|
|
16523
16526
|
error: error instanceof Error ? error.message : "Network error"
|
|
@@ -16594,9 +16597,23 @@ async function resetPassword(token2, newPassword) {
|
|
|
16594
16597
|
};
|
|
16595
16598
|
}
|
|
16596
16599
|
}
|
|
16600
|
+
function validatePassword(password) {
|
|
16601
|
+
if (!password) return "";
|
|
16602
|
+
if (password.length < 6) {
|
|
16603
|
+
return "Password must be at least 6 characters";
|
|
16604
|
+
}
|
|
16605
|
+
const uniqueChars = new Set(password).size;
|
|
16606
|
+
if (uniqueChars < 2) {
|
|
16607
|
+
return "Password must contain at least 2 different characters";
|
|
16608
|
+
}
|
|
16609
|
+
return "";
|
|
16610
|
+
}
|
|
16611
|
+
function isPasswordValid(password) {
|
|
16612
|
+
return validatePassword(password) === "";
|
|
16613
|
+
}
|
|
16597
16614
|
const _sfc_main$8 = defineComponent({
|
|
16598
16615
|
name: "UserRegistration",
|
|
16599
|
-
emits: ["toggle"],
|
|
16616
|
+
emits: ["toggle", "signup-success"],
|
|
16600
16617
|
data() {
|
|
16601
16618
|
return {
|
|
16602
16619
|
email: "",
|
|
@@ -16630,6 +16647,9 @@ const _sfc_main$8 = defineComponent({
|
|
|
16630
16647
|
color: this.badLoginAttempt ? "error" : "success",
|
|
16631
16648
|
text: this.badLoginAttempt ? "Try again" : "Log In"
|
|
16632
16649
|
};
|
|
16650
|
+
},
|
|
16651
|
+
passwordError() {
|
|
16652
|
+
return validatePassword(this.password);
|
|
16633
16653
|
}
|
|
16634
16654
|
},
|
|
16635
16655
|
async created() {
|
|
@@ -16655,6 +16675,14 @@ const _sfc_main$8 = defineComponent({
|
|
|
16655
16675
|
},
|
|
16656
16676
|
async createUser() {
|
|
16657
16677
|
this.awaitingResponse = true;
|
|
16678
|
+
if (this.passwordError) {
|
|
16679
|
+
alertUser({
|
|
16680
|
+
text: this.passwordError,
|
|
16681
|
+
status: Status.error
|
|
16682
|
+
});
|
|
16683
|
+
this.awaitingResponse = false;
|
|
16684
|
+
return;
|
|
16685
|
+
}
|
|
16658
16686
|
log(`
|
|
16659
16687
|
User creation
|
|
16660
16688
|
-------------
|
|
@@ -16665,7 +16693,10 @@ Teacher: ${this.teacher}
|
|
|
16665
16693
|
Author: ${this.author}
|
|
16666
16694
|
`);
|
|
16667
16695
|
if (this.password === this.retypedPassword) {
|
|
16668
|
-
if (!this.user)
|
|
16696
|
+
if (!this.user) {
|
|
16697
|
+
console.error("ERROR: No user object available");
|
|
16698
|
+
return;
|
|
16699
|
+
}
|
|
16669
16700
|
this.user.createAccount(this.username, this.password).then(async (resp) => {
|
|
16670
16701
|
if (resp.status === Status.ok) {
|
|
16671
16702
|
this.authStore.loginAndRegistration.loggedIn = true;
|
|
@@ -16676,7 +16707,7 @@ Author: ${this.author}
|
|
|
16676
16707
|
const currentUser = await getCurrentUser();
|
|
16677
16708
|
await currentUser.setConfig({ email: this.email });
|
|
16678
16709
|
const origin = typeof window !== "undefined" ? window.location.origin : void 0;
|
|
16679
|
-
const verificationResult = await sendVerificationEmail(this.username, origin);
|
|
16710
|
+
const verificationResult = await sendVerificationEmail(this.username, this.email, origin);
|
|
16680
16711
|
if (verificationResult.ok) {
|
|
16681
16712
|
alertUser({
|
|
16682
16713
|
text: "Account created! Please check your email to verify your account.",
|
|
@@ -16686,10 +16717,12 @@ Author: ${this.author}
|
|
|
16686
16717
|
log(`Warning: Failed to send verification email: ${verificationResult.error}`);
|
|
16687
16718
|
}
|
|
16688
16719
|
} catch (emailError) {
|
|
16720
|
+
console.error("Email save/send error:", emailError);
|
|
16689
16721
|
log(`Warning: Failed to save email or send verification: ${emailError}`);
|
|
16690
16722
|
}
|
|
16691
16723
|
}
|
|
16692
|
-
|
|
16724
|
+
const username = (await getCurrentUser()).getUsername();
|
|
16725
|
+
this.$emit("signup-success", { username });
|
|
16693
16726
|
} else {
|
|
16694
16727
|
if (resp.error === "This username is taken!") {
|
|
16695
16728
|
this.usernameError = true;
|
|
@@ -16707,11 +16740,14 @@ Author: ${this.author}
|
|
|
16707
16740
|
}
|
|
16708
16741
|
}
|
|
16709
16742
|
}).catch((e) => {
|
|
16710
|
-
|
|
16743
|
+
console.error("createAccount error:", e);
|
|
16744
|
+
if (e) {
|
|
16745
|
+
const errorText = e?.message || e?.error || e?.toString() || "Account creation failed";
|
|
16711
16746
|
alertUser({
|
|
16712
|
-
text:
|
|
16747
|
+
text: errorText,
|
|
16713
16748
|
status: Status.error
|
|
16714
16749
|
});
|
|
16750
|
+
}
|
|
16715
16751
|
});
|
|
16716
16752
|
this.awaitingResponse = false;
|
|
16717
16753
|
} else {
|
|
@@ -16781,12 +16817,13 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
16781
16817
|
name: "password",
|
|
16782
16818
|
hover: "Show password",
|
|
16783
16819
|
label: "Create a password",
|
|
16784
|
-
hint:
|
|
16820
|
+
hint: _ctx.passwordError,
|
|
16821
|
+
error: !!_ctx.passwordError,
|
|
16785
16822
|
min: "4",
|
|
16786
16823
|
"append-icon": _ctx.passwordVisible ? "mdi-eye-off" : "mdi-eye",
|
|
16787
16824
|
type: _ctx.passwordVisible ? "text" : "password",
|
|
16788
16825
|
"onClick:append": _cache[3] || (_cache[3] = () => _ctx.passwordVisible = !_ctx.passwordVisible)
|
|
16789
|
-
}, null, 8, ["modelValue", "append-icon", "type"]),
|
|
16826
|
+
}, null, 8, ["modelValue", "hint", "error", "append-icon", "type"]),
|
|
16790
16827
|
createVNode(_component_v_text_field, {
|
|
16791
16828
|
modelValue: _ctx.retypedPassword,
|
|
16792
16829
|
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => _ctx.retypedPassword = $event),
|
|
@@ -16823,7 +16860,8 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
16823
16860
|
class: "mr-2",
|
|
16824
16861
|
type: "submit",
|
|
16825
16862
|
loading: _ctx.awaitingResponse,
|
|
16826
|
-
color: _ctx.buttonStatus.color
|
|
16863
|
+
color: _ctx.buttonStatus.color,
|
|
16864
|
+
disabled: !!_ctx.passwordError || _ctx.password !== _ctx.retypedPassword
|
|
16827
16865
|
}, {
|
|
16828
16866
|
default: withCtx(() => [
|
|
16829
16867
|
createVNode(_component_v_icon, { start: "" }, {
|
|
@@ -16835,7 +16873,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
16835
16873
|
_cache[11] || (_cache[11] = createTextVNode(" Create Account "))
|
|
16836
16874
|
]),
|
|
16837
16875
|
_: 1
|
|
16838
|
-
}, 8, ["loading", "color"]),
|
|
16876
|
+
}, 8, ["loading", "color", "disabled"]),
|
|
16839
16877
|
_ctx.registrationRoute ? (openBlock(), createBlock(_component_router_link, {
|
|
16840
16878
|
key: 0,
|
|
16841
16879
|
to: "login"
|
|
@@ -18680,6 +18718,7 @@ export {
|
|
|
18680
18718
|
getCurrentUser,
|
|
18681
18719
|
isComponent,
|
|
18682
18720
|
isDefineComponent,
|
|
18721
|
+
isPasswordValid,
|
|
18683
18722
|
isQuestionView,
|
|
18684
18723
|
piniaPlugin,
|
|
18685
18724
|
requestPasswordReset,
|
|
@@ -18693,6 +18732,7 @@ export {
|
|
|
18693
18732
|
useConfigStore,
|
|
18694
18733
|
useQuestionView,
|
|
18695
18734
|
useViewable,
|
|
18735
|
+
validatePassword,
|
|
18696
18736
|
verifyEmail
|
|
18697
18737
|
};
|
|
18698
18738
|
//# sourceMappingURL=common-ui.es.js.map
|