or3-provider-basic-auth 0.0.12 → 0.0.14
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/README.md +177 -0
- package/dist/module.json +1 -1
- package/dist/runtime/assets/signin-hero-dark.webp +0 -0
- package/dist/runtime/assets/signin-hero-light.webp +0 -0
- package/dist/runtime/assets/signup-clouds-bottom-dark.webp +0 -0
- package/dist/runtime/assets/signup-clouds-bottom-light.webp +0 -0
- package/dist/runtime/assets/signup-hero-dark.webp +0 -0
- package/dist/runtime/assets/signup-hero-light.webp +0 -0
- package/dist/runtime/components/BasicAuthChangePasswordModal.client.vue +31 -5
- package/dist/runtime/components/BasicAuthLockPage.client.d.vue.ts +13 -1
- package/dist/runtime/components/BasicAuthLockPage.client.vue +68 -15
- package/dist/runtime/components/BasicAuthLockPage.client.vue.d.ts +13 -1
- package/dist/runtime/components/BasicAuthRegisterModal.client.d.vue.ts +1 -0
- package/dist/runtime/components/BasicAuthRegisterModal.client.vue +91 -31
- package/dist/runtime/components/BasicAuthRegisterModal.client.vue.d.ts +1 -0
- package/dist/runtime/components/BasicAuthSignInModal.client.d.vue.ts +2 -1
- package/dist/runtime/components/BasicAuthSignInModal.client.vue +71 -35
- package/dist/runtime/components/BasicAuthSignInModal.client.vue.d.ts +2 -1
- package/dist/runtime/components/SidebarAuthButtonBasic.client.d.vue.ts +9 -1
- package/dist/runtime/components/SidebarAuthButtonBasic.client.vue +33 -44
- package/dist/runtime/components/SidebarAuthButtonBasic.client.vue.d.ts +9 -1
- package/dist/runtime/lib/constants.d.ts +2 -0
- package/dist/runtime/lib/constants.js +1 -0
- package/dist/runtime/plugins/auth-status.client.js +7 -2
- package/dist/runtime/plugins/basic-auth-ui.client.js +4 -2
- package/dist/runtime/server/api/basic-auth/_helpers.js +1 -1
- package/dist/runtime/server/api/basic-auth/change-password.post.js +2 -2
- package/dist/runtime/server/api/basic-auth/register.post.js +19 -11
- package/dist/runtime/server/api/basic-auth/sign-in.post.js +14 -13
- package/dist/runtime/server/api/basic-auth/sign-out.post.js +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,6 +8,139 @@ This package registers:
|
|
|
8
8
|
- `ProviderTokenBroker` (`basic-auth`)
|
|
9
9
|
- admin status adapter (`auth-basic-auth`)
|
|
10
10
|
- provider-owned auth UI adapter + components
|
|
11
|
+
- Client status and silent-refresh recovery adapters activate only while SSR auth is enabled and Basic Auth is selected; inactive modules preserve the active auth provider's adapters.
|
|
12
|
+
|
|
13
|
+
## Lock page UI
|
|
14
|
+
|
|
15
|
+
The auth UI adapter registers `signInComponent` for direct host requests. It uses
|
|
16
|
+
the existing sign-in/registration flow in `modalOnly` mode with Nuxt UI's `open`,
|
|
17
|
+
`close`, and `after:leave` overlay lifecycle, so chat cards and blocked sends can
|
|
18
|
+
open sign-in without first opening a sidebar or mobile menu. This requires the
|
|
19
|
+
updated host and a rebuilt provider.
|
|
20
|
+
|
|
21
|
+
The lock-page adapter uses an email-first form: **Continue with email** opens
|
|
22
|
+
registration with the address filled in, and **Existing account? Sign in** opens
|
|
23
|
+
the password sign-in dialog. When the host's public `registrationMode` is
|
|
24
|
+
`disabled`, Continue opens sign-in instead. Invite-only registration continues to
|
|
25
|
+
require a valid invite, and invite links retain their automatic registration
|
|
26
|
+
handoff. No account is created until the registration dialog is submitted.
|
|
27
|
+
|
|
28
|
+
`BasicAuthSignInModal` and `BasicAuthRegisterModal` accept an optional
|
|
29
|
+
`initialEmail` prop, applied when the dialog opens. Existing callers can omit it.
|
|
30
|
+
The registered lock-page component also exposes an optional `email-form` slot
|
|
31
|
+
with `{ state }` (`state.email` is writable). A trusted host extension can replace
|
|
32
|
+
the primary email form while retaining the provider's sign-in and registration
|
|
33
|
+
dialogs. When an invite token is present, the provider always uses its original
|
|
34
|
+
form and automatic invite handoff, regardless of the slot. With no slot, behavior
|
|
35
|
+
is unchanged. This slot requires rebuilding/upgrading the provider.
|
|
36
|
+
The OR3 host supplies the branded preview, logo, headline, and responsive layout,
|
|
37
|
+
including lightweight WebP sky scenes, handwritten captions, and an overlapping
|
|
38
|
+
mobile sign-in card that adapts to screen height. The host footer links to
|
|
39
|
+
`https://or3.net` (Learn more) and `https://github.com/Saluana/or3-chat` (GitHub)
|
|
40
|
+
in new tabs. The mobile email label remains
|
|
41
|
+
accessible while the field displays an envelope icon and placeholder. Custom adapters
|
|
42
|
+
continue to own the full page. This UI requires rebuilding the provider and host;
|
|
43
|
+
published installations need a provider release and updated host pin.
|
|
44
|
+
|
|
45
|
+
The host handles session-check failures with retry controls and explains denied
|
|
46
|
+
workspace access for authenticated accounts. Safe post-authentication redirects
|
|
47
|
+
retain query strings and fragments and reject destinations back to the lock page.
|
|
48
|
+
|
|
49
|
+
The registration dialog uses the host's configured branding and theme colors,
|
|
50
|
+
with the welcoming birds perched on a cloud bank in the card's top-right corner,
|
|
51
|
+
a cloud strip along the footer, labeled icon fields, and inline sign-in and
|
|
52
|
+
account actions. Day and night versions of the artwork follow the host's `.dark`
|
|
53
|
+
class. On small screens the illustration stays a compact top-right accent, the
|
|
54
|
+
card scrolls, and the actions fill the available width. Decorative images are
|
|
55
|
+
excluded from the accessibility tree; the dialog keeps its accessible title,
|
|
56
|
+
description, focus handling, and existing validation and invite handoff. The
|
|
57
|
+
four WebP assets ship inside the provider's runtime and only the active mode's
|
|
58
|
+
pair is loaded, so no external image service is required. Rebuild
|
|
59
|
+
the provider for local source development; published installations require an
|
|
60
|
+
updated provider version.
|
|
61
|
+
|
|
62
|
+
<details>
|
|
63
|
+
<summary>Registration artwork generation prompts</summary>
|
|
64
|
+
|
|
65
|
+
Four independent generations with the built-in imagegen tool, each using only
|
|
66
|
+
the original modal mockup as its reference; no earlier artwork was used as input,
|
|
67
|
+
so the night versions are similar to, not pixel-aligned with, the day versions.
|
|
68
|
+
The prompts requested a 2304×1536 canvas, but the tool returned 1536×1024
|
|
69
|
+
transparent PNGs. Each was cropped to its artwork and encoded as WebP with alpha
|
|
70
|
+
using `cwebp -q 84 -alpha_q 95 -m 6 -sharp_yuv` (hero: `-crop 300 0 1236 1024
|
|
71
|
+
-resize 760 0`; footer: `-crop 0 660 1536 364 -resize 1408 0`). Assets:
|
|
72
|
+
`src/runtime/assets/signup-hero-{light,dark}.webp` and
|
|
73
|
+
`src/runtime/assets/signup-clouds-bottom-{light,dark}.webp`. Both heroes keep the
|
|
74
|
+
birds within the top 72% of the image; the modal fades only the cloud below that.
|
|
75
|
+
|
|
76
|
+
**Hero, day**
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
Use case: stylized-concept. Generate a NEW high-resolution standalone illustration, using ONLY the attached mockup as the visual reference. Reconstruct the small decorative birds-and-clouds scene at the UPPER RIGHT OF THE WHITE MODAL faithfully at much higher quality. This is reference-based new generation, not an edit of any earlier generated asset.
|
|
80
|
+
Output: 2304×1536 landscape PNG with a truly transparent background.
|
|
81
|
+
|
|
82
|
+
Match the reference's characters, silhouettes, proportions and poses: the sage-green hummingbird is on the left and slightly behind, with a cream belly, a long slender dark beak pointing diagonally UPPER LEFT, an excited open orange mouth, a small rounded feather crest sweeping right and an open fan-shaped wing on the left. The smaller cobalt-blue chick is on the right in front, facing slightly up-left toward the viewer, with a short orange open beak, cream chest, compact swept crest and a little extended wing to the right. Use the mockup's charming compact, softly rounded 3D animation style with a subtle matte velvety finish and clear eyes. Preserve their appealing simple anatomy; fine detail should clarify the reference rather than redesign it. Add the same small green chirp marks beside the hummingbird.
|
|
83
|
+
|
|
84
|
+
The birds nestle into the same soft white cloud bank shown in the mockup, partly hidden at the belly. Clouds have broad smooth blended lobes, very pale cyan shading and diffuse daylight, with soft edges. Keep the reference's clean, restrained cloud forms: neither separate spherical balls nor detailed storm-cloud texture. The bank extends off the TOP and RIGHT edges. At left and bottom it softly dissipates to real alpha transparency. Keep the entire group in the right two-thirds of the canvas, the left third mostly transparent, and the upper-right small corner clear of birds for the app's close control.
|
|
85
|
+
Only recreate that upper-right artwork. Do not include the modal, logo, text, controls, background webpage or the separate birds in a nest at the bottom-left of the screenshot. No isolated cloud dots, bubbles, glossy spheres, long fur, grainy vapor or fractal cloud texture. No background rectangle or sky fill.
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Footer clouds, day**
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
Use case: stylized-concept. Generate a NEW high-resolution transparent cloud-edge asset using ONLY the attached original UI mockup as the reference. Reconstruct the QUIET CLOUD EDGING AT THE VERY BOTTOM OF THE WHITE MODAL, faithfully and at much higher quality. This is fresh reference-based generation, not an edit of earlier generated clouds.
|
|
92
|
+
Output: 2304×1536 landscape PNG, true alpha transparency.
|
|
93
|
+
|
|
94
|
+
Match the reference's very soft, simple stylized 3D clouds: broad gently merged white cloud masses with faint pale-cyan shading, diffuse daylight and softly feathered edges. A few overlapping smooth puffs of varied size make a low cloud cluster at the bottom-left and a slightly taller cluster at the bottom-right; the middle stays almost empty with only a faint low haze along the bottom. Keep this airy and restrained like the mockup, leaving generous negative space for the form. Confine all visible cloud masses to the bottom quarter of the canvas; upper three-quarters fully transparent. Run the clouds off left, right and bottom edges. The cloud tops dissolve softly into alpha. Recreate the broad reference forms without adding visual detail the mockup does not have.
|
|
95
|
+
|
|
96
|
+
No birds, nest, text, logo, green marks, buttons, interface, or background webpage. No separated spheres, balls, bubbles, bead-like dots, shiny highlights, dense towering clouds, realistic weather texture, fur or fractal cotton. No sky or white background fill; the surrounding canvas is truly transparent.
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Hero, night**
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
Use case: stylized-concept. Generate a NEW high-resolution standalone illustration, using ONLY the attached mockup as the visual reference. Reconstruct the small decorative birds-and-clouds scene at the UPPER RIGHT OF THE WHITE MODAL faithfully at much higher quality. This is reference-based new generation, not an edit of any earlier generated asset.
|
|
103
|
+
Output: 2304×1536 landscape PNG with a truly transparent background.
|
|
104
|
+
|
|
105
|
+
Create a calm NIGHT-MODE counterpart directly from the mockup reference. Match the reference's characters, silhouettes, proportions and poses: the sage-green hummingbird is on the left and slightly behind, with a cream belly, a long slender dark beak pointing diagonally UPPER LEFT, an excited open orange mouth, a small rounded feather crest sweeping right and an open fan-shaped wing on the left. The smaller cobalt-blue chick is on the right in front, facing slightly up-left toward the viewer, with a short orange open beak, cream chest, compact swept crest and a little extended wing to the right. Use the mockup's charming compact, softly rounded 3D animation style with a subtle matte velvety finish and clear eyes. Preserve their appealing simple anatomy; fine detail should clarify the reference rather than redesign it. Add the same small green chirp marks beside the hummingbird.
|
|
106
|
+
|
|
107
|
+
The birds nestle into the same soft slate-blue cloud bank shown in the mockup, partly hidden at the belly. Clouds have broad smooth blended lobes, low-contrast slate-blue bodies (#1f2f4a to #2c4166) and diffuse cool moonlight, with soft edges. Keep the reference's clean, restrained cloud forms: neither separate spherical balls nor detailed storm-cloud texture. The bank extends off the TOP and RIGHT edges. At left and bottom it softly dissipates to real alpha transparency. Keep the entire group in the right two-thirds of the canvas, the left third mostly transparent, and the upper-right small corner clear of birds for the app's close control.
|
|
108
|
+
Only recreate that upper-right artwork. Do not include the modal, logo, text, controls, background webpage or the separate birds in a nest at the bottom-left of the screenshot. No isolated cloud dots, bubbles, glossy spheres, long fur, grainy vapor or fractal cloud texture. No background rectangle or sky fill.
|
|
109
|
+
Night lighting is a broad gentle gradient across the cloud bank, subtly lighter on upper surfaces, darker below. Preserve each bird's natural sage-green, cobalt-blue, cream and orange colours under soft cool illumination so both stay readable and vivid. No bright moonlit rims, no glowing outlines around puffs, no stars, no navy background fill. Keep the same compact character poses and smooth, simple cloud treatment as the original mockup.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Footer clouds, night**
|
|
113
|
+
|
|
114
|
+
```text
|
|
115
|
+
Use case: stylized-concept. Generate a NEW high-resolution transparent cloud-edge asset using ONLY the attached original UI mockup as the reference. Reconstruct the QUIET CLOUD EDGING AT THE VERY BOTTOM OF THE WHITE MODAL, faithfully and at much higher quality. This is fresh reference-based generation, not an edit of earlier generated clouds.
|
|
116
|
+
Output: 2304×1536 landscape PNG, true alpha transparency.
|
|
117
|
+
|
|
118
|
+
Create a calm NIGHT-MODE counterpart directly from the mockup reference. Match the reference's very soft, simple stylized 3D clouds: broad gently merged slate-blue cloud masses (#1f2f4a to #2c4166) with subtle diffuse moonlight and softly feathered edges. A few overlapping smooth puffs of varied size make a low cloud cluster at the bottom-left and a slightly taller cluster at the bottom-right; the middle stays almost empty with only a faint low haze along the bottom. Keep this airy and restrained like the mockup, leaving generous negative space for the form. Confine all visible cloud masses to the bottom quarter of the canvas; upper three-quarters fully transparent. Run the clouds off left, right and bottom edges. The cloud tops dissolve softly into alpha. Recreate the broad reference forms without adding visual detail the mockup does not have.
|
|
119
|
+
|
|
120
|
+
No birds, nest, text, logo, green marks, buttons, interface, or background webpage. No separated spheres, balls, bubbles, bead-like dots, shiny highlights, dense towering clouds, realistic weather texture, fur or fractal cotton. No sky or white background fill; the surrounding canvas is truly transparent.
|
|
121
|
+
Use a gentle broad lighting gradient that is slightly lighter on cloud tops and darker underneath. The cloud edging stays quiet and low contrast. No bright rim light, no white/glowing contour lines around individual puffs, no stars, and no black or navy background fill. Upper negative space remains true alpha transparency.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
</details>
|
|
125
|
+
|
|
126
|
+
## Sign-in dialog
|
|
127
|
+
|
|
128
|
+
The sign-in dialog welcomes returning users with **Welcome back** and **Pick up
|
|
129
|
+
where you left off.**, the configured site logo, and a blue bird seated in clouds.
|
|
130
|
+
It matches the registration dialog's 44rem maximum width and responsive control
|
|
131
|
+
sizes, with labeled email/password fields and icons, an inline
|
|
132
|
+
**Don’t have an account? Create account** action, and Cancel/Sign in buttons. The
|
|
133
|
+
card adapts to short screens and phones, with keyboard focus and accessible error
|
|
134
|
+
announcements. Email prefilling, invitation forwarding and credential submission
|
|
135
|
+
keep their existing behavior.
|
|
136
|
+
|
|
137
|
+
Day/night hero illustrations were generated independently with the built-in
|
|
138
|
+
imagegen tool directly from the sign-in mockup. The originals are 1536×1024
|
|
139
|
+
transparent PNGs; the shipped `signin-hero-{light,dark}.webp` files are 1200×800,
|
|
140
|
+
encoded with `cwebp -q 84 -alpha_q 95 -m 6 -sharp_yuv -resize 1200 0`. The footer
|
|
141
|
+
reuses the registration cloud edging. Only the active theme's artwork loads, and
|
|
142
|
+
all illustration is decorative. Rebuild the provider to see source changes;
|
|
143
|
+
published installations require an updated provider release.
|
|
11
144
|
|
|
12
145
|
## Installation
|
|
13
146
|
|
|
@@ -58,6 +191,23 @@ Registration mode is a core-auth policy, not a provider setting:
|
|
|
58
191
|
- `OR3_AUTH_REGISTRATION_MODE=open|invite_only|disabled`
|
|
59
192
|
- `OR3_AUTH_INVITE_TOKEN_SECRET` and `OR3_AUTH_INVITE_TOKEN_TTL_SECONDS` (required for `invite_only`)
|
|
60
193
|
|
|
194
|
+
Creating invitations also requires `OR3_AUTH_INVITE_TOKEN_SECRET` in open
|
|
195
|
+
registration mode. When it is missing, **Admin → Registration → Invitations** explains how
|
|
196
|
+
to set it and restart OR3, with a link to the host's
|
|
197
|
+
`/documentation/cloud/environment-reference#invite-signing-setup` guide. No
|
|
198
|
+
invitation is created until the secret is configured.
|
|
199
|
+
|
|
200
|
+
The host's **Admin → Registration** page groups **Settings** and **Invitations**.
|
|
201
|
+
Settings saves open, invite-only, or closed registration to
|
|
202
|
+
`OR3_AUTH_REGISTRATION_MODE` in the server's `.env` and distinguishes the saved
|
|
203
|
+
mode from the current mode until OR3 restarts. The restart notice offers
|
|
204
|
+
**Restart now** with confirmation when the owner has dashboard restart access
|
|
205
|
+
(`OR3_ADMIN_ALLOW_RESTART=true`); development servers need a manual restart.
|
|
206
|
+
Reload after the server returns to check the active mode. It also reports
|
|
207
|
+
invitation setup status and prevents saving invite-only mode without the configured signing
|
|
208
|
+
secret. Creating, copying, viewing, and revoking signup invites live in the
|
|
209
|
+
Invitations tab; the old `/admin/signup-invites` link redirects there.
|
|
210
|
+
|
|
61
211
|
Strict-mode behavior:
|
|
62
212
|
|
|
63
213
|
- `NODE_ENV=production`, `OR3_STRICT_CONFIG=true`, or runtime config `auth.strict=true` fails startup if required secrets are missing.
|
|
@@ -95,6 +245,19 @@ Strict-mode behavior:
|
|
|
95
245
|
|
|
96
246
|
New passwords must be at least eight characters and no more than 72 UTF-8 bytes, matching bcrypt's input limit. Existing account hashes remain verifiable, including passwords created before this limit was enforced.
|
|
97
247
|
|
|
248
|
+
Registration and password-change forms say **Use at least 8 characters**. If a password exceeds the limit, they ask the user to shorten it without exposing encoding terminology. This copy change does not change password validation.
|
|
249
|
+
|
|
250
|
+
The registration form labels the invitation field **Invite code** with the placeholder **Paste invite code**. Invite links still fill in the code automatically.
|
|
251
|
+
|
|
252
|
+
Registration distinguishes a different email on a signed, unexpired invitation from
|
|
253
|
+
an invalid or expired code. An email mismatch asks users to check for typos or use
|
|
254
|
+
the email that received the invitation, without disclosing that address. Invalid
|
|
255
|
+
codes ask users to check their invite link or request a new invitation; a missing
|
|
256
|
+
required code asks them to enter one. Form entries survive a rejected attempt,
|
|
257
|
+
which does not create credentials or accept the invitation. Email matching ignores
|
|
258
|
+
capitalization. The host exposes `invite_email_mismatch` for this preflight result;
|
|
259
|
+
rebuild both the updated host and provider to adopt it.
|
|
260
|
+
|
|
98
261
|
The registered sidebar auth adapter accepts `layout="rail"` (default) and
|
|
99
262
|
`layout="more-sheet"`. In the More sheet it renders Account/Login with the
|
|
100
263
|
host's shared full-width `.more-row` structure, while keeping the existing
|
|
@@ -163,3 +326,17 @@ The updated host distinguishes signup invites from existing team invites. Signup
|
|
|
163
326
|
Registration preflight rejects invalid invites before credential creation, including in open mode. It resolves the explicit body token first, followed by the host's header, HttpOnly cookie, query, and Referer precedence. A valid token is retained in the invite cookie for canonical session resolution; an explicit replacement overrides a stale cookie. Without a token, open registration remains available. If credentials commit before canonical acceptance, use Already registered? Sign in with the same account and a valid or replacement invite. The sign-in request preserves manually pasted tokens, verifies the signed-in email, and uses the existing HttpOnly invite cookie. The selected sync store still owns atomic acceptance; provider-only credentials grant no protected OR3 access. No credential lifecycle or recovery service is added.
|
|
164
327
|
|
|
165
328
|
Provider-only tests use the exact host registration and token sources pinned in `tests/fixtures/host`, with SHA-256 provenance verified by Vitest. No sibling checkout is required. To exercise the current host integration, run `OR3_CANONICAL_HOST_ROOT=/absolute/path/to/or3-chat bun run test`. Refresh the pinned files and provenance together when adopting a reviewed host contract change; do not replace the host validation logic with a provider-local implementation.
|
|
329
|
+
|
|
330
|
+
### Short signup codes
|
|
331
|
+
|
|
332
|
+
New signup invitations use eight random characters (shown as `K7MP-4X9Q`) and retain clickable invite links. Lowercase, spaces, and an optional dash are accepted. The host hashes codes with HMAC using `OR3_AUTH_INVITE_TOKEN_SECRET`, shares a 20/minute/IP lookup limit across invitation entry points, and preserves email binding, expiry, revocation, and atomic single use. Previously issued signed links remain supported. Codes and hashes are omitted from invitation history.
|
|
333
|
+
|
|
334
|
+
The updated host and SQLite or Convex store must provide short-code resolution. Registration and replacement-code sign-in call the host preflight; backend acceptance remains the source of workspace access.
|
|
335
|
+
|
|
336
|
+
### Session and account feedback
|
|
337
|
+
|
|
338
|
+
The sidebar reads the host's shared session and emits `or3:auth-session-changed` after sign-in, registration, sign-out, or a password change. The host owns refreshing the session and deciding whether account changes require a reload. Session probes disable automatic request retries.
|
|
339
|
+
|
|
340
|
+
Invite-only registration marks the code as required before submission. Invalid or expired invitation messages explain the next step for the current registration mode. Sign-out also clears the pending invitation cookie so it cannot apply to another signup. Password changes explain that all sessions are revoked, report incorrect-password and rate-limit errors, and show a one-time confirmation on the sign-in screen.
|
|
341
|
+
|
|
342
|
+
These source changes require a new provider package release and a coordinated host dependency pin. The existing `0.0.13` package does not include them.
|
package/dist/module.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
<USeparator />
|
|
33
33
|
|
|
34
|
-
<UFormField label="New Password" name="newPassword" hint="
|
|
34
|
+
<UFormField label="New Password" name="newPassword" hint="Use at least 8 characters">
|
|
35
35
|
<UInput
|
|
36
36
|
v-model="state.newPassword"
|
|
37
37
|
type="password"
|
|
@@ -53,8 +53,13 @@
|
|
|
53
53
|
/>
|
|
54
54
|
</UFormField>
|
|
55
55
|
|
|
56
|
+
<p class="text-xs opacity-70">
|
|
57
|
+
For your security, changing your password signs you out on all devices.
|
|
58
|
+
</p>
|
|
59
|
+
|
|
56
60
|
<div
|
|
57
61
|
v-if="errorMessage"
|
|
62
|
+
role="alert"
|
|
58
63
|
class="flex items-start gap-2 rounded-[var(--md-border-radius)] border border-[var(--md-error)]/30 bg-[var(--md-error)]/8 px-3 py-2.5 text-sm text-[var(--md-error)]"
|
|
59
64
|
>
|
|
60
65
|
<UIcon name="i-lucide-alert-circle" class="w-4 h-4 mt-0.5 shrink-0" />
|
|
@@ -83,6 +88,7 @@
|
|
|
83
88
|
|
|
84
89
|
<script setup>
|
|
85
90
|
import { computed, reactive, ref } from "vue";
|
|
91
|
+
import { PASSWORD_UPDATED_NOTICE_KEY } from "../lib/constants";
|
|
86
92
|
import { newPasswordFitsBcrypt } from "../password-policy";
|
|
87
93
|
const modalUi = {
|
|
88
94
|
overlay: "basic-auth-modal-overlay",
|
|
@@ -108,17 +114,33 @@ function close() {
|
|
|
108
114
|
errorMessage.value = "";
|
|
109
115
|
emit("update:modelValue", false);
|
|
110
116
|
}
|
|
117
|
+
function describeError(error) {
|
|
118
|
+
const failure = error;
|
|
119
|
+
const status = Number(failure?.statusCode);
|
|
120
|
+
const serverMessage = failure?.data?.statusMessage;
|
|
121
|
+
if (status === 401) {
|
|
122
|
+
return serverMessage === "Session expired" ? "Your session has expired. Sign in again to change your password." : "Your current password is incorrect.";
|
|
123
|
+
}
|
|
124
|
+
if (status === 429) {
|
|
125
|
+
const seconds = Number(failure?.response?.headers?.get?.("retry-after"));
|
|
126
|
+
return seconds > 0 ? `Too many attempts. Try again in ${seconds} seconds.` : "Too many attempts. Please wait a minute and try again.";
|
|
127
|
+
}
|
|
128
|
+
if (status === 400 && serverMessage && serverMessage !== "Invalid request") {
|
|
129
|
+
return serverMessage;
|
|
130
|
+
}
|
|
131
|
+
return "Unable to change password right now. Please try again.";
|
|
132
|
+
}
|
|
111
133
|
async function onSubmit() {
|
|
112
134
|
if (state.newPassword.length < 8) {
|
|
113
135
|
errorMessage.value = "New password must be at least 8 characters.";
|
|
114
136
|
return;
|
|
115
137
|
}
|
|
116
138
|
if (!newPasswordFitsBcrypt(state.newPassword)) {
|
|
117
|
-
errorMessage.value = "
|
|
139
|
+
errorMessage.value = "Password is too long. Please shorten it.";
|
|
118
140
|
return;
|
|
119
141
|
}
|
|
120
142
|
if (state.newPassword !== state.confirmNewPassword) {
|
|
121
|
-
errorMessage.value = "Passwords
|
|
143
|
+
errorMessage.value = "Passwords must match.";
|
|
122
144
|
return;
|
|
123
145
|
}
|
|
124
146
|
pending.value = true;
|
|
@@ -132,10 +154,14 @@ async function onSubmit() {
|
|
|
132
154
|
confirmNewPassword: state.confirmNewPassword
|
|
133
155
|
}
|
|
134
156
|
});
|
|
157
|
+
try {
|
|
158
|
+
sessionStorage.setItem(PASSWORD_UPDATED_NOTICE_KEY, "1");
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
135
161
|
emit("updated");
|
|
136
162
|
close();
|
|
137
|
-
} catch {
|
|
138
|
-
errorMessage.value =
|
|
163
|
+
} catch (error) {
|
|
164
|
+
errorMessage.value = describeError(error);
|
|
139
165
|
} finally {
|
|
140
166
|
pending.value = false;
|
|
141
167
|
}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare var __VLS_1: {
|
|
2
|
+
state: any;
|
|
3
|
+
};
|
|
4
|
+
type __VLS_Slots = {} & {
|
|
5
|
+
'email-form'?: (props: typeof __VLS_1) => any;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
9
|
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -1,22 +1,44 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
<div class="lock-page-auth">
|
|
3
|
+
<slot v-if="$slots['email-form'] && !inviteToken" name="email-form" :state="state" />
|
|
4
|
+
<UForm v-else :state="state" @submit="continueWithEmail">
|
|
5
|
+
<UFormField label="Email address" name="email" :ui="{ label: 'lock-page-email-label', container: 'lock-page-email-container' }">
|
|
6
|
+
<UInput
|
|
7
|
+
v-model="state.email"
|
|
8
|
+
type="email"
|
|
9
|
+
name="email"
|
|
10
|
+
placeholder="you@example.com"
|
|
11
|
+
icon="i-lucide-mail"
|
|
12
|
+
autocomplete="email"
|
|
13
|
+
required
|
|
14
|
+
class="w-full"
|
|
15
|
+
style="padding-inline-start: var(--lock-email-inset, 1rem) !important; outline: var(--lock-email-focus, none) !important; outline-offset: 2px"
|
|
16
|
+
:ui="{ base: 'lock-page-email-input', leading: 'lock-page-email-leading', leadingIcon: 'size-5' }"
|
|
17
|
+
/>
|
|
18
|
+
</UFormField>
|
|
19
|
+
<UButton
|
|
20
|
+
block
|
|
21
|
+
type="submit"
|
|
22
|
+
size="xl"
|
|
23
|
+
color="neutral"
|
|
24
|
+
trailing-icon="i-lucide-arrow-right"
|
|
25
|
+
class="lock-page-continue"
|
|
26
|
+
:ui="{ label: 'tracking-normal', trailingIcon: 'size-5 ms-0' }"
|
|
27
|
+
>
|
|
28
|
+
Continue with email
|
|
29
|
+
</UButton>
|
|
30
|
+
</UForm>
|
|
13
31
|
|
|
14
|
-
<
|
|
15
|
-
|
|
32
|
+
<div class="lock-page-divider" aria-hidden="true"><span>OR</span></div>
|
|
33
|
+
|
|
34
|
+
<p class="lock-page-existing">
|
|
35
|
+
Existing account?
|
|
36
|
+
<button type="button" class="lock-page-sign-in" @click="signInModalOpen = true">Sign in</button>
|
|
16
37
|
</p>
|
|
17
38
|
|
|
18
39
|
<BasicAuthSignInModal
|
|
19
40
|
v-model="signInModalOpen"
|
|
41
|
+
:initial-email="state.email"
|
|
20
42
|
:invite-token="inviteToken"
|
|
21
43
|
@signed-in="handleSignedIn"
|
|
22
44
|
@open-register="openRegisterFromSignIn"
|
|
@@ -24,6 +46,7 @@
|
|
|
24
46
|
|
|
25
47
|
<BasicAuthRegisterModal
|
|
26
48
|
v-model="registerModalOpen"
|
|
49
|
+
:initial-email="state.email"
|
|
27
50
|
:invite-token="inviteToken"
|
|
28
51
|
@open-sign-in="openSignInFromRegister"
|
|
29
52
|
@registered="handleRegistered"
|
|
@@ -32,18 +55,44 @@
|
|
|
32
55
|
</template>
|
|
33
56
|
|
|
34
57
|
<script setup>
|
|
35
|
-
import { nextTick, onMounted, ref } from "vue";
|
|
58
|
+
import { nextTick, onMounted, reactive, ref } from "vue";
|
|
59
|
+
import { useRuntimeConfig, useToast } from "#imports";
|
|
60
|
+
import { PASSWORD_UPDATED_NOTICE_KEY } from "../lib/constants";
|
|
36
61
|
import BasicAuthRegisterModal from "./BasicAuthRegisterModal.client.vue";
|
|
37
62
|
import BasicAuthSignInModal from "./BasicAuthSignInModal.client.vue";
|
|
38
63
|
import { claimInviteLinkAutoOpen, readInviteLinkToken } from "../lib/invite-link.client";
|
|
39
|
-
const
|
|
64
|
+
const runtimeConfig = useRuntimeConfig();
|
|
65
|
+
const toast = useToast();
|
|
66
|
+
const state = reactive({ email: "" });
|
|
40
67
|
const signInModalOpen = ref(false);
|
|
41
68
|
const registerModalOpen = ref(false);
|
|
42
69
|
const inviteToken = ref(null);
|
|
43
70
|
onMounted(() => {
|
|
44
71
|
inviteToken.value = readInviteLinkToken();
|
|
45
72
|
if (claimInviteLinkAutoOpen()) registerModalOpen.value = true;
|
|
73
|
+
showPasswordUpdatedNotice();
|
|
46
74
|
});
|
|
75
|
+
function showPasswordUpdatedNotice() {
|
|
76
|
+
try {
|
|
77
|
+
if (!sessionStorage.getItem(PASSWORD_UPDATED_NOTICE_KEY)) return;
|
|
78
|
+
sessionStorage.removeItem(PASSWORD_UPDATED_NOTICE_KEY);
|
|
79
|
+
} catch {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
toast.add({
|
|
83
|
+
title: "Password updated",
|
|
84
|
+
description: "You were signed out on all devices. Sign in with your new password.",
|
|
85
|
+
color: "success"
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function continueWithEmail() {
|
|
89
|
+
state.email = state.email.trim();
|
|
90
|
+
if (runtimeConfig.public?.registrationMode === "disabled") {
|
|
91
|
+
signInModalOpen.value = true;
|
|
92
|
+
} else {
|
|
93
|
+
registerModalOpen.value = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
47
96
|
function notifyAuthSessionChanged() {
|
|
48
97
|
if (typeof window === "undefined") return;
|
|
49
98
|
window.dispatchEvent(new CustomEvent("or3:auth-session-changed"));
|
|
@@ -68,3 +117,7 @@ async function openSignInFromRegister(token) {
|
|
|
68
117
|
signInModalOpen.value = true;
|
|
69
118
|
}
|
|
70
119
|
</script>
|
|
120
|
+
|
|
121
|
+
<style scoped>
|
|
122
|
+
.lock-page-auth :deep(.lock-page-email-leading),.lock-page-divider{display:none}.lock-page-auth :deep(.lock-page-email-label){color:var(--md-on-surface);font-size:.875rem;line-height:1.5;padding-inline:0}.lock-page-auth :deep(.lock-page-email-container){margin-top:.375rem}.lock-page-auth :deep(.lock-page-email-input){background:var(--md-surface);border:1px solid var(--md-outline-variant,var(--md-border-color));border-radius:var(--md-border-radius);box-shadow:none;font-size:1rem;height:3rem;padding-inline:1rem}.lock-page-auth :deep(.lock-page-email-input:focus-visible){--lock-email-focus:2px solid var(--md-primary)}.lock-page-auth :deep(.lock-page-continue){background:var(--md-on-surface);border-radius:var(--md-border-radius);box-shadow:none;color:var(--md-surface);font-size:1rem;font-weight:500;gap:.75rem;margin-top:.875rem;min-height:3.25rem}.lock-page-auth :deep(.lock-page-continue:hover){background:color-mix(in srgb,var(--md-on-surface) 90%,var(--md-surface))}.lock-page-existing{color:var(--md-on-surface-variant);font-size:.875rem;margin-top:.75rem;text-align:center}.lock-page-sign-in{align-items:center;border-radius:.25rem;color:var(--md-on-surface);cursor:pointer;display:inline-flex;font:inherit;font-weight:500;min-height:44px;padding-inline:.125rem;text-decoration:underline;text-decoration-color:color-mix(in srgb,currentColor 45%,transparent);text-decoration-thickness:1px;text-underline-offset:4px;transition:text-decoration-color .15s ease}.lock-page-sign-in:hover{text-decoration-color:currentColor}.lock-page-sign-in:focus-visible{outline:2px solid var(--md-primary);outline-offset:2px}@media (width < 80rem){.lock-page-auth{--lock-email-inset:3rem}.lock-page-auth :deep(.lock-page-email-label){clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.lock-page-auth :deep(.lock-page-email-leading){color:#8492a3;display:flex;padding-inline-start:1rem}.lock-page-auth :deep(.lock-page-email-container){margin-top:0!important}.lock-page-auth :deep(.lock-page-email-input){background:color-mix(in srgb,var(--lock-card,#fff) 80%,transparent);border:1px solid color-mix(in srgb,var(--lock-muted,#667385) 22%,transparent);border-radius:.875rem;color:var(--lock-ink,#0c1420);font-size:1rem;height:clamp(2.75rem,6.2svh,3.125rem);padding-inline-start:3rem}.lock-page-auth :deep(.lock-page-email-input::-moz-placeholder){color:#8592a3}.lock-page-auth :deep(.lock-page-email-input::placeholder){color:#8592a3}.lock-page-auth :deep(.lock-page-continue){background:#0d1115;border-radius:1rem;box-shadow:0 8px 14px -8px rgba(31,56,74,.4);color:#fff;font-size:1rem;font-weight:600;margin-top:.625rem;min-height:clamp(2.75rem,6.5svh,3.25rem)}.lock-page-auth :deep(.lock-page-continue:hover){background:#242e38}.dark .lock-page-auth :deep(.lock-page-continue){background:#eef3f6;box-shadow:none;color:#0d1115}.dark .lock-page-auth :deep(.lock-page-continue:hover){background:#fff}.lock-page-divider{align-items:center;color:var(--lock-muted,#667385);display:flex;font-size:.6875rem;gap:.8125rem;letter-spacing:.08em;line-height:.9375rem;margin-top:clamp(1rem,3svh,1.5rem)}.lock-page-divider:after,.lock-page-divider:before{background:color-mix(in srgb,var(--lock-muted,#667385) 24%,transparent);content:"";flex:1;height:1px}.lock-page-existing{color:var(--lock-muted,#667385);font-size:.875rem;margin-top:.5rem}.lock-page-sign-in{color:var(--lock-ink,#0c1420);font-weight:600}}@media (width < 35rem) and (height <= 38.75rem){.lock-page-divider{margin-top:.625rem}.lock-page-existing{margin-top:0}}@media (width >= 35rem) and (width < 80rem) and (height <= 31.25rem){.lock-page-divider{margin-top:.625rem}.lock-page-existing{margin-top:0}}
|
|
123
|
+
</style>
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare var __VLS_1: {
|
|
2
|
+
state: any;
|
|
3
|
+
};
|
|
4
|
+
type __VLS_Slots = {} & {
|
|
5
|
+
'email-form'?: (props: typeof __VLS_1) => any;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
9
|
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -2,6 +2,7 @@ type __VLS_Props = {
|
|
|
2
2
|
modelValue: boolean;
|
|
3
3
|
/** Token from an invite link; filled in when the form opens. */
|
|
4
4
|
inviteToken?: string | null;
|
|
5
|
+
initialEmail?: string;
|
|
5
6
|
};
|
|
6
7
|
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
7
8
|
"update:modelValue": (value: boolean) => any;
|