MongocampLogin
FormKit schema-driven login form. Persists the last entered user ID in a cookie (mongocamp_login, 30 days) and redirects to redirectPath (default /) on success.
Usage
<template>
<MongocampLogin redirect-path="/dashboard" />
</template>Props
| Prop | Type | Default | Description |
|---|---|---|---|
redirectPath | string | '/' | Path to navigate to after a successful login. |
userIdType | 'email' | 'text' | 'email' | 'email' labels the first field Email and checks the address; 'text' labels it User and takes any MongoCamp user id (a server's own admin, demo-reader). |
hideHeading | boolean | false | Hide the heading inside the card, e.g. when the page or the header slot already has one. |
passwordless | boolean | 'only' | false | Server 3.0 with AUTH_PASSWORDLESS=true: true adds E-mail me a login code instead, 'only' shows nothing else (see below). |
forgotPassword | boolean | false | Server 3.0 with AUTH_PASSWORD_RESET=true: a Forgot password? link below the form, to paths.resetPassword (MongocampResetPassword). |
Login by e-mail (server 3.0)
With passwordless the card asks for the address ⇒ useMongocampAuth().requestLoginLink (always 202: if the address has an account, a mail with a code and a login link is on its way), then for the 6-digit code of the mail ⇒ loginWithLink({ email, code }) and on to redirectPath. The mail's link logs in too, on MongocampLoginLink. A wrong, used or expired code (400, code 4403 — after 5 wrong codes the code ends) says so, 429 shows the wait (wrong codes count as failed logins with RATE_LIMIT_LOGIN), 404 = not switched on. Use another address or get a new code goes back to the address; with true a link switches between password and e-mail.
Slots
| Slot | Where |
|---|---|
header | Inside the card, above the form — a logo, a title, a hint. |
footer | Inside the card, below the form and its error message — links, legal text. |
<template>
<MongocampLogin
redirect-path="/secured"
hide-heading
>
<template #header>
<h2>Sign in to the console</h2>
</template>
<template #footer>
<p>Ask your administrator for an account.</p>
</template>
</MongocampLogin>
</template>Behavior
- Fields:
userId(email, required) andpassword(required, min length 3), rendered vianuxtUIInput. Both fill the card's width. - Calls
login(userId, password)fromuseMongocampAuth()(provided by@sfxcode/nuxt-mongocamp-server). - On success: saves
userIdto themongocamp_logincookie and navigates toredirectPath. - On failure: shows a generic "Wrong Login or Password !" message — not the API's actual error message, so failures never leak server-side details into the UI.
- Server 2.11
RATE_LIMIT_LOGIN: after too many failed logins the server refuses every login for a while (429, also with the right password) — the form says "Too many failed logins. Try again in 7 s." (the seconds fromRetry-After; without the header, "Wait a moment and try again.").