Implements, verifies, and archives the three remaining Wave 2 changes from openspec/MIGRATION-PLAN.md. - add-wallet-settlement (P3): demo recharge, guarded withdrawal freeze and one-time admin review, paginated own fund entries, idempotent per-shop weekly/monthly settlement statements with commission rate and one-time payout confirmation. - add-merchant-onboarding (P5): personal/enterprise applications with one live application per user, guarded review with mandatory rejection reason, and transactional shop + owner provisioning returning one-time credentials; mall onboarding/status pages and an admin review console. - add-membership-messaging (P7): platform member levels, append-only growth accrual on order completion with guarded one-way leveling, order/shipment/ refund system messages with unread/read state and soft deletion, plus the mall header unread badge. Backend: migrations 0019-0023, new wallet, settlement, merchant_onboarding, membership and messaging modules, event hooks in order/fulfillment/aftersale, and integration suites for each. Shared contract extended and all three frontends updated; code indexes, domain docs, backend guidelines and the migration tracker synced. Verification: cargo test -p vmall-api green twice consecutively; mall, admin and shop-admin builds pass; browser smoke on every new surface; openspec validate --all --strict green (33 passed). The three changes share the @vmall/shared contract, the mall mock adapter and per-app locale/nav files, so they are committed together to keep every commit buildable.
128 lines
4.1 KiB
Vue
128 lines
4.1 KiB
Vue
<script setup lang="ts">
|
|
import { ApiError } from "@vmall/shared";
|
|
|
|
const { t } = useI18n();
|
|
const { $api } = useNuxtApp();
|
|
const session = useSessionStore();
|
|
const router = useRouter();
|
|
const route = useRoute();
|
|
|
|
const displayName = ref("");
|
|
const email = ref("");
|
|
const password = ref("");
|
|
const confirmPassword = ref("");
|
|
const errorKey = ref("");
|
|
const submitting = ref(false);
|
|
|
|
/**
|
|
* Where to go after registering. Same-origin absolute paths only, so a crafted
|
|
* query cannot turn registration into an open redirect.
|
|
*/
|
|
const redirectTarget = computed((): string => {
|
|
const raw = route.query.redirect;
|
|
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
return typeof value === "string" && value.startsWith("/") && !value.startsWith("//")
|
|
? value
|
|
: "/";
|
|
});
|
|
|
|
/** Mirrors the auth API's rule so a short password fails here, not as a 400. */
|
|
const MIN_PASSWORD_LENGTH = 8;
|
|
|
|
function validate(): boolean {
|
|
if (!displayName.value || !email.value || !password.value || !confirmPassword.value) {
|
|
errorKey.value = "auth.validationRequired";
|
|
return false;
|
|
}
|
|
if (!/^\S+@\S+\.\S+$/.test(email.value)) {
|
|
errorKey.value = "auth.validationEmail";
|
|
return false;
|
|
}
|
|
if (password.value.length < MIN_PASSWORD_LENGTH) {
|
|
errorKey.value = "auth.validationPassword";
|
|
return false;
|
|
}
|
|
if (password.value !== confirmPassword.value) {
|
|
errorKey.value = "auth.validationMismatch";
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
async function submit(): Promise<void> {
|
|
errorKey.value = "";
|
|
if (!validate()) return;
|
|
submitting.value = true;
|
|
try {
|
|
const auth = await $api.register(email.value, password.value, displayName.value);
|
|
session.setAuth(auth);
|
|
await router.push(redirectTarget.value);
|
|
} catch (error) {
|
|
errorKey.value =
|
|
error instanceof ApiError && error.status === 409 ? "auth.emailTaken" : "auth.requestFailed";
|
|
} finally {
|
|
submitting.value = false;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<section class="bg-bg text-text min-h-screen px-5 py-10 font-sans">
|
|
<VCard class="mx-auto my-10 max-w-[420px] p-6 sm:p-10">
|
|
<div class="border-border mb-6 flex items-baseline gap-4 border-b pb-3.5">
|
|
<h1 class="m-0 text-xl font-semibold">{{ t("auth.registerTab") }}</h1>
|
|
<NuxtLink class="text-primary hover:text-primary-hover text-sm" to="/login">{{
|
|
t("auth.loginTab")
|
|
}}</NuxtLink>
|
|
</div>
|
|
<form @submit.prevent="submit">
|
|
<VField :label="t('common.displayName')">
|
|
<VInput
|
|
v-model.trim="displayName"
|
|
type="text"
|
|
autocomplete="name"
|
|
:placeholder="t('auth.displayNamePlaceholder')"
|
|
/>
|
|
</VField>
|
|
<VField :label="t('common.email')">
|
|
<VInput
|
|
v-model.trim="email"
|
|
type="email"
|
|
autocomplete="email"
|
|
:placeholder="t('auth.emailPlaceholder')"
|
|
/>
|
|
</VField>
|
|
<VField :label="t('common.password')">
|
|
<VInput
|
|
v-model="password"
|
|
type="password"
|
|
autocomplete="new-password"
|
|
:placeholder="t('auth.passwordPlaceholder')"
|
|
/>
|
|
</VField>
|
|
<VField :label="t('auth.confirmPassword')">
|
|
<VInput
|
|
v-model="confirmPassword"
|
|
type="password"
|
|
autocomplete="new-password"
|
|
:placeholder="t('auth.confirmPasswordPlaceholder')"
|
|
/>
|
|
</VField>
|
|
<p v-if="errorKey" class="text-danger -mt-1 mb-3 text-xs">{{ t(errorKey) }}</p>
|
|
<VBtn class="mt-1 w-full" variant="primary" type="submit" :disabled="submitting">
|
|
{{ t("auth.registerAction") }}
|
|
</VBtn>
|
|
</form>
|
|
<div class="text-muted mt-4 flex flex-wrap items-center gap-2 text-xs">
|
|
<span>{{ t("auth.haveAccount") }}</span>
|
|
<NuxtLink class="text-primary hover:text-primary-hover" to="/login">{{
|
|
t("auth.loginNow")
|
|
}}</NuxtLink>
|
|
<NuxtLink class="text-primary hover:text-primary-hover" to="/forgot-password">{{
|
|
t("auth.forgotPassword")
|
|
}}</NuxtLink>
|
|
</div>
|
|
</VCard>
|
|
</section>
|
|
</template>
|