@jskit-ai/auth-web 0.2.11 → 0.2.13
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/CHANGELOG.md +9 -0
- package/fixtures/sign-in/main.js +3 -2
- package/locales/en.json +13 -3
- package/package.json +10 -9
- package/src/client/composables/loginView/confirmationLink.js +38 -0
- package/src/client/composables/loginView/useLoginViewActions.js +84 -7
- package/src/client/composables/loginView/useLoginViewState.js +20 -1
- package/src/client/composables/loginView/useLoginViewValidation.js +3 -0
- package/src/client/runtime/useLoginView.js +8 -0
- package/src/client/views/AuthProfileWidget.vue +2 -8
- package/src/client/views/DefaultLoginView.vue +102 -41
- package/src/client/views/DefaultResetPasswordView.vue +2 -3
- package/src/client/views/DefaultSignOutView.vue +5 -6
- package/src/server/AuthWebFeature.js +4 -2
- package/src/server/authRateLimits.js +59 -0
- package/src/server/authWeb.js +5 -2
- package/src/server/constants/authActionIds.js +1 -0
- package/src/server/controllers/AuthController.js +18 -1
- package/src/server/routes/authRoutes.js +38 -46
- package/src/server/services/AuthWebService.js +7 -0
- package/test/authRateLimits.test.js +92 -0
- package/test/clientSurface.test.js +7 -3
- package/test/loginViewActions.test.js +45 -0
- package/test/providerRuntime.test.js +64 -0
- package/test/signIn.browser.test.js +128 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- While the app has no account (`features.firstAccountSetupCode`), the registration form explains that the first account becomes the owner and asks for the setup code from the server's log or its hosting service, and sends it as `setupCode`. New message keys: `jskit.auth.login.firstAccount.explain` and `jskit.auth.login.field.setupCode`.
|
|
6
|
+
- Email confirmation on the sign-in page: "Confirm your email" has a field for the emailed link or its code, and in development, when the registration's answer carries the link, shows it with a button that confirms it. Opening the emailed link (`/auth/login?confirmation_token=...`) confirms it and takes the code out of the address. Confirming signs the person in and opens the requested page. A sign-in refused with `auth.login.emailUnconfirmed` opens "Confirm your email" instead of an error. New route `POST /api/register/confirm`, which writes the new session's cookies, limited by `config.auth.rateLimits.registerConfirm` (10 a minute); the register answer carries `confirmationUrl` when the provider gives it. New message keys: `jskit.auth.register.confirmed`, `jskit.auth.login.field.confirmationCode`, `jskit.auth.login.confirmEmail.confirm`, `.devLink`, `.useDevLink` and `jskit.auth.login.error.confirmRegistrationFailed`.
|
|
7
|
+
- The auth routes' rate limits apply, per client address: `login`, `register`, `loginOtpRequest` and `loginOtpVerify` 10 a minute; `registerConfirmationResend` and `passwordForgot` 5; `oauthStart`, `oauthComplete`, `passwordRecovery` and `passwordReset` 20; `devLoginAs` 30. A refused request answers 429 with `kernel.http.rateLimited` and `Retry-After`, and the login page shows it.
|
|
8
|
+
- `config.auth.rateLimits.<route>` changes a route's limit (`{ max, timeWindow }`, merged over the default) or removes it (`false`); an unknown route name or a malformed value stops startup. `AuthWebFeature` therefore requires `runtime.config`, which every installed runtime provides.
|
|
9
|
+
- The sign-in and sign-out screens use Material 3 colour roles and type: an elevated card on `surface-container` (the whole screen on phones), the selected sign-in mode on `secondary-container`, and the remembered-account and email-confirmation notes on `secondary-container`, without the tinted gradient and borders. The profile menu's button is Material 3's 40dp text button inside material-web's 48dp touch target instead of a fixed 48px height.
|
|
10
|
+
- Icons are Material Symbols `$aliases` (from `@jskit-ai/material-web`) instead of `@mdi/js` paths, and text uses Vuetify 4's Material 3 type classes (`text-body-large`, `text-title-medium`, ...) instead of Material 2 ones, which Vuetify 4 no longer styles. Upgrading: see the guide's [Move an app to the Material 3 defaults](https://mobily-enterprises.github.io/jskit-ai/guide/app-setup/material-3-migration).
|
|
11
|
+
|
|
3
12
|
## 0.2.0 - 2026-10-29
|
|
4
13
|
|
|
5
14
|
- Translation ready: every user-visible text is a message key with its English in `locales/en.json`, so an app translates it by supplying translation files only. With no translations, texts and behaviour are unchanged. See the guide "Translating a JSKIT app".
|
package/fixtures/sign-in/main.js
CHANGED
|
@@ -3,10 +3,11 @@ import { createPinia } from "pinia";
|
|
|
3
3
|
import { createRouter, createWebHistory, RouterView } from "vue-router";
|
|
4
4
|
import { QueryClient, VueQueryPlugin } from "@tanstack/vue-query";
|
|
5
5
|
import "vuetify/styles";
|
|
6
|
+
import "@jskit-ai/material-web/client/material.css";
|
|
7
|
+
import { createMaterialVuetifyOptions } from "@jskit-ai/material-web/client";
|
|
6
8
|
import { createVuetify } from "vuetify";
|
|
7
9
|
import * as components from "vuetify/components";
|
|
8
10
|
import * as directives from "vuetify/directives";
|
|
9
|
-
import { aliases, mdi } from "vuetify/iconsets/mdi-svg";
|
|
10
11
|
import { SHELL_WEB_ERROR_RUNTIME_KEY } from "@jskit-ai/shell-web/client/error";
|
|
11
12
|
import { SHELL_WEB_PLACEMENT_RUNTIME_KEY } from "@jskit-ai/shell-web/client/placement";
|
|
12
13
|
import AuthProfileWidget from "../../src/client/views/AuthProfileWidget.vue";
|
|
@@ -82,7 +83,7 @@ app.provide(SHELL_WEB_ERROR_RUNTIME_KEY, errorRuntime);
|
|
|
82
83
|
app.use(pinia);
|
|
83
84
|
app.use(router);
|
|
84
85
|
app.use(VueQueryPlugin, { queryClient: new QueryClient({ defaultOptions: { queries: { retry: false } } }) });
|
|
85
|
-
app.use(createVuetify({ components, directives,
|
|
86
|
+
app.use(createVuetify({ components, directives, ...createMaterialVuetifyOptions() }));
|
|
86
87
|
// The kernel hands an absent optional capability to a provider as null.
|
|
87
88
|
const outputs = AuthWebClientProvider.setup({
|
|
88
89
|
components: { register() {} },
|
package/locales/en.json
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"jskit": {
|
|
3
3
|
"auth": {
|
|
4
4
|
"register": {
|
|
5
|
-
"confirmEmail": "Check your email to confirm the account before logging in."
|
|
5
|
+
"confirmEmail": "Check your email to confirm the account before logging in.",
|
|
6
|
+
"confirmed": "Your email is confirmed."
|
|
6
7
|
},
|
|
7
8
|
"login": {
|
|
8
9
|
"title": {
|
|
@@ -33,13 +34,21 @@
|
|
|
33
34
|
"email": "Email",
|
|
34
35
|
"password": "Password",
|
|
35
36
|
"confirmPassword": "Confirm password",
|
|
36
|
-
"otpCode": "One-time code"
|
|
37
|
+
"otpCode": "One-time code",
|
|
38
|
+
"confirmationCode": "Confirmation link or code",
|
|
39
|
+
"setupCode": "Setup code"
|
|
37
40
|
},
|
|
38
41
|
"confirmEmail": {
|
|
39
42
|
"message": "Please confirm your email address. After confirmation, you can sign in.",
|
|
40
43
|
"goToMainScreen": "Go to main screen",
|
|
41
44
|
"resend": "Resend confirmation email",
|
|
42
|
-
"resent": "If an account exists for that email, a confirmation email has been sent."
|
|
45
|
+
"resent": "If an account exists for that email, a confirmation email has been sent.",
|
|
46
|
+
"confirm": "Confirm",
|
|
47
|
+
"devLink": "Development: no email is sent, so here is the confirmation link.",
|
|
48
|
+
"useDevLink": "Confirm with this link"
|
|
49
|
+
},
|
|
50
|
+
"firstAccount": {
|
|
51
|
+
"explain": "This app has no account yet. Its first account becomes its owner, so it needs the setup code the server wrote in its log when it started, or that its hosting service shows its owner."
|
|
43
52
|
},
|
|
44
53
|
"rememberedAccount": {
|
|
45
54
|
"welcomeBack": "Welcome back, {name}",
|
|
@@ -74,6 +83,7 @@
|
|
|
74
83
|
"otpRequestFailed": "Unable to request one-time code.",
|
|
75
84
|
"emailRequiredForConfirmation": "Enter an email address before requesting confirmation.",
|
|
76
85
|
"resendConfirmationFailed": "Unable to resend confirmation email.",
|
|
86
|
+
"confirmRegistrationFailed": "Unable to confirm the email address.",
|
|
77
87
|
"oauthCompleteFailed": "Unable to complete OAuth sign-in.",
|
|
78
88
|
"oauthProviderInvalid": "OAuth provider id is invalid.",
|
|
79
89
|
"oauthReturnToInvalid": "OAuth return path is invalid.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/auth-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test --test-concurrency=1"
|
|
@@ -24,19 +24,16 @@
|
|
|
24
24
|
"./test/playwright": "./src/test/playwright.js",
|
|
25
25
|
"./locales/en.json": "./locales/en.json"
|
|
26
26
|
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@mdi/js": "^7.4.47"
|
|
29
|
-
},
|
|
30
27
|
"peerDependencies": {
|
|
31
|
-
"@jskit-ai/auth-core": "0.2.
|
|
32
|
-
"@jskit-ai/http-runtime": "0.2.
|
|
33
|
-
"@jskit-ai/kernel": "0.2.
|
|
34
|
-
"@jskit-ai/shell-web": "0.2.
|
|
28
|
+
"@jskit-ai/auth-core": "0.2.10",
|
|
29
|
+
"@jskit-ai/http-runtime": "0.2.10",
|
|
30
|
+
"@jskit-ai/kernel": "0.2.10",
|
|
31
|
+
"@jskit-ai/shell-web": "0.2.11",
|
|
35
32
|
"@tanstack/vue-query": "^5.90.5",
|
|
36
33
|
"pinia": "^4.0.3",
|
|
37
34
|
"vue": "^3.5.44",
|
|
38
35
|
"vue-router": "^5.3.1",
|
|
39
|
-
"vuetify": "^4.
|
|
36
|
+
"vuetify": "^4.3.0"
|
|
40
37
|
},
|
|
41
38
|
"description": "Auth web module: Fastify auth routes plus web login/sign-out scaffolds.",
|
|
42
39
|
"jskit": {
|
|
@@ -48,6 +45,7 @@
|
|
|
48
45
|
"requires": [
|
|
49
46
|
"auth.service",
|
|
50
47
|
"runtime.actions",
|
|
48
|
+
"runtime.config",
|
|
51
49
|
"runtime.env",
|
|
52
50
|
"runtime.http"
|
|
53
51
|
]
|
|
@@ -305,5 +303,8 @@
|
|
|
305
303
|
"singleton": true
|
|
306
304
|
}
|
|
307
305
|
}
|
|
306
|
+
},
|
|
307
|
+
"devDependencies": {
|
|
308
|
+
"@jskit-ai/material-web": "0.1.0"
|
|
308
309
|
}
|
|
309
310
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { pageLocation, pageWindow } from "../../browser.js";
|
|
2
|
+
|
|
3
|
+
// The query parameter of the link a registration's confirmation email carries.
|
|
4
|
+
const CONFIRMATION_TOKEN_PARAM = "confirmation_token";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The code in a pasted confirmation link, or the pasted text itself when it is
|
|
8
|
+
* the bare code.
|
|
9
|
+
* @param {unknown} input
|
|
10
|
+
*/
|
|
11
|
+
function confirmationTokenFromInput(input) {
|
|
12
|
+
const text = String(input || "").trim();
|
|
13
|
+
try {
|
|
14
|
+
return String(new URL(text).searchParams.get(CONFIRMATION_TOKEN_PARAM) || "").trim() || text;
|
|
15
|
+
} catch {
|
|
16
|
+
return text;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Takes the confirmation code out of the page's address, so reloading the page
|
|
22
|
+
* or sharing its address does not send it again; "" when there is none.
|
|
23
|
+
*/
|
|
24
|
+
function takeConfirmationTokenFromLocation() {
|
|
25
|
+
const location = pageLocation();
|
|
26
|
+
if (!location) {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
const url = new URL(location.href);
|
|
30
|
+
const token = String(url.searchParams.get(CONFIRMATION_TOKEN_PARAM) || "").trim();
|
|
31
|
+
if (token) {
|
|
32
|
+
url.searchParams.delete(CONFIRMATION_TOKEN_PARAM);
|
|
33
|
+
pageWindow()?.history.replaceState({}, "", `${url.pathname}${url.search}${url.hash}`);
|
|
34
|
+
}
|
|
35
|
+
return token;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { CONFIRMATION_TOKEN_PARAM, confirmationTokenFromInput, takeConfirmationTokenFromLocation };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { mdiGoogle } from "@mdi/js";
|
|
2
1
|
import { authRegisterCommand } from "@jskit-ai/auth-core/shared/commands/authRegisterCommand";
|
|
3
2
|
import { authRegisterConfirmationResendCommand } from "@jskit-ai/auth-core/shared/commands/authRegisterConfirmationResendCommand";
|
|
3
|
+
import { authRegisterConfirmCommand } from "@jskit-ai/auth-core/shared/commands/authRegisterConfirmCommand";
|
|
4
4
|
import { authLoginPasswordCommand } from "@jskit-ai/auth-core/shared/commands/authLoginPasswordCommand";
|
|
5
5
|
import { authLoginOtpRequestCommand } from "@jskit-ai/auth-core/shared/commands/authLoginOtpRequestCommand";
|
|
6
6
|
import { authLoginOtpVerifyCommand } from "@jskit-ai/auth-core/shared/commands/authLoginOtpVerifyCommand";
|
|
@@ -16,6 +16,7 @@ import { stripOAuthParamsFromLocation } from "./oauthCallbackUrl.js";
|
|
|
16
16
|
import { completeOAuthPopupSignIn } from "../../runtime/popupOAuthLaunchClient.js";
|
|
17
17
|
import { ensureCommandSectionValid } from "./validationHelpers.js";
|
|
18
18
|
import { resolveRegisterCompletionState } from "./registerCompletion.js";
|
|
19
|
+
import { confirmationTokenFromInput, takeConfirmationTokenFromLocation } from "./confirmationLink.js";
|
|
19
20
|
import { inactiveSessionMessage } from "../../runtime/inactiveSessionMessage.js";
|
|
20
21
|
import { replacePage } from "../../browser.js";
|
|
21
22
|
import { useJskitText } from "../../i18n.js";
|
|
@@ -160,6 +161,10 @@ export function useLoginViewActions({ state, validation, queryClient, errorRunti
|
|
|
160
161
|
email: normalizedEmail,
|
|
161
162
|
password: String(state.password.value || "")
|
|
162
163
|
};
|
|
164
|
+
const setupCode = String(state.setupCode.value || "").trim();
|
|
165
|
+
if (setupCode) {
|
|
166
|
+
registerPayload.setupCode = setupCode;
|
|
167
|
+
}
|
|
163
168
|
const invitationToken = String(state.invitationToken.value || "").trim();
|
|
164
169
|
if (invitationToken) {
|
|
165
170
|
registerPayload.invitation = {
|
|
@@ -183,7 +188,8 @@ export function useLoginViewActions({ state, validation, queryClient, errorRunti
|
|
|
183
188
|
if (!registerCompletion.shouldCompleteLogin) {
|
|
184
189
|
state.enterEmailConfirmationPendingState({
|
|
185
190
|
emailAddress: normalizedEmail,
|
|
186
|
-
message: registerCompletion.message
|
|
191
|
+
message: registerCompletion.message,
|
|
192
|
+
confirmationUrl: registerResult?.confirmationUrl
|
|
187
193
|
});
|
|
188
194
|
return;
|
|
189
195
|
}
|
|
@@ -239,10 +245,21 @@ export function useLoginViewActions({ state, validation, queryClient, errorRunti
|
|
|
239
245
|
};
|
|
240
246
|
ensureCommandSectionValid(authLoginPasswordCommand, "body", loginPayload, t("jskit.auth.login.error.signInFailed"));
|
|
241
247
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
248
|
+
let loginResult;
|
|
249
|
+
try {
|
|
250
|
+
loginResult = await request(AUTH_PATHS.LOGIN, {
|
|
251
|
+
method: "POST",
|
|
252
|
+
body: loginPayload
|
|
253
|
+
});
|
|
254
|
+
} catch (error) {
|
|
255
|
+
// The right password for a registration still waiting for its email:
|
|
256
|
+
// show how to confirm it instead of a failed sign-in.
|
|
257
|
+
if (error?.code !== "auth.login.emailUnconfirmed") {
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
state.enterEmailConfirmationPendingState({ emailAddress: normalizedEmail, message: serverMessage(error) });
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
246
263
|
state.applyRememberedAccountPreference({
|
|
247
264
|
email: normalizedEmail,
|
|
248
265
|
displayName: loginResult?.username || normalizedEmail,
|
|
@@ -303,6 +320,10 @@ export function useLoginViewActions({ state, validation, queryClient, errorRunti
|
|
|
303
320
|
}
|
|
304
321
|
|
|
305
322
|
async function submitAuth() {
|
|
323
|
+
if (state.isEmailConfirmationPending.value) {
|
|
324
|
+
await confirmRegistrationCode();
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
306
327
|
state.submitAttempted.value = true;
|
|
307
328
|
clearTransientMessages();
|
|
308
329
|
if (!validation.canSubmit.value) {
|
|
@@ -389,6 +410,9 @@ export function useLoginViewActions({ state, validation, queryClient, errorRunti
|
|
|
389
410
|
body: resendPayload
|
|
390
411
|
});
|
|
391
412
|
const info = serverMessage(resendResult).trim() || t("jskit.auth.login.confirmEmail.resent");
|
|
413
|
+
if (resendResult?.confirmationUrl) {
|
|
414
|
+
state.confirmationUrl.value = resendResult.confirmationUrl;
|
|
415
|
+
}
|
|
392
416
|
setInfoMessage(info, "auth-web.default-login-view:register-confirmation-resend");
|
|
393
417
|
} catch (error) {
|
|
394
418
|
setErrorMessage(serverMessage(error, t("jskit.auth.login.error.resendConfirmationFailed")));
|
|
@@ -397,6 +421,51 @@ export function useLoginViewActions({ state, validation, queryClient, errorRunti
|
|
|
397
421
|
}
|
|
398
422
|
}
|
|
399
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Confirms a registration from its link's code, or from the whole link,
|
|
426
|
+
* which signs the person in, and opens the requested page.
|
|
427
|
+
* @param {unknown} codeOrLink
|
|
428
|
+
*/
|
|
429
|
+
async function confirmRegistration(codeOrLink) {
|
|
430
|
+
const confirmPayload = { token: confirmationTokenFromInput(codeOrLink) };
|
|
431
|
+
state.registrationConfirmPending.value = true;
|
|
432
|
+
clearTransientMessages();
|
|
433
|
+
try {
|
|
434
|
+
ensureCommandSectionValid(
|
|
435
|
+
authRegisterConfirmCommand,
|
|
436
|
+
"body",
|
|
437
|
+
confirmPayload,
|
|
438
|
+
t("jskit.auth.login.error.confirmRegistrationFailed")
|
|
439
|
+
);
|
|
440
|
+
const confirmResult = await request(AUTH_PATHS.REGISTER_CONFIRM, {
|
|
441
|
+
method: "POST",
|
|
442
|
+
body: confirmPayload
|
|
443
|
+
});
|
|
444
|
+
state.applyRememberedAccountPreference({
|
|
445
|
+
email: confirmResult?.email,
|
|
446
|
+
displayName: confirmResult?.username || confirmResult?.email,
|
|
447
|
+
shouldRemember: state.rememberAccountOnDevice.value !== false
|
|
448
|
+
});
|
|
449
|
+
setInfoMessage(
|
|
450
|
+
serverMessage(confirmResult).trim() || t("jskit.auth.register.confirmed"),
|
|
451
|
+
"auth-web.default-login-view:register-confirmed"
|
|
452
|
+
);
|
|
453
|
+
await completeLogin();
|
|
454
|
+
} catch (error) {
|
|
455
|
+
setErrorMessage(serverMessage(error, t("jskit.auth.login.error.confirmRegistrationFailed")));
|
|
456
|
+
} finally {
|
|
457
|
+
state.registrationConfirmPending.value = false;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function confirmRegistrationCode() {
|
|
462
|
+
return confirmRegistration(state.confirmationCode.value);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function confirmRegistrationFromLink() {
|
|
466
|
+
return confirmRegistration(state.confirmationUrl.value);
|
|
467
|
+
}
|
|
468
|
+
|
|
400
469
|
function oauthProviderButtonLabel(provider) {
|
|
401
470
|
const providerLabel = String(provider?.label || provider?.id || t("jskit.auth.login.oauth.providerFallback"));
|
|
402
471
|
if (state.isRegister.value) {
|
|
@@ -413,7 +482,7 @@ export function useLoginViewActions({ state, validation, queryClient, errorRunti
|
|
|
413
482
|
|
|
414
483
|
function oauthProviderIcon(provider) {
|
|
415
484
|
if (String(provider?.id || "").toLowerCase() === "google") {
|
|
416
|
-
return
|
|
485
|
+
return "$google";
|
|
417
486
|
}
|
|
418
487
|
return undefined;
|
|
419
488
|
}
|
|
@@ -461,9 +530,15 @@ export function useLoginViewActions({ state, validation, queryClient, errorRunti
|
|
|
461
530
|
|
|
462
531
|
async function initializeOnMounted() {
|
|
463
532
|
state.applyRememberedAccountHint(readRememberedAccountHint());
|
|
533
|
+
// Opened from a registration's confirmation email.
|
|
534
|
+
const confirmationToken = takeConfirmationTokenFromLocation();
|
|
464
535
|
state.loading.value = true;
|
|
465
536
|
try {
|
|
466
537
|
const session = await refreshSession();
|
|
538
|
+
if (confirmationToken) {
|
|
539
|
+
await confirmRegistration(confirmationToken);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
467
542
|
const callbackHandled = await handleOAuthCallbackIfPresent();
|
|
468
543
|
if (!callbackHandled && session?.authenticated) {
|
|
469
544
|
replacePage(state.requestedReturnTo.value);
|
|
@@ -495,6 +570,8 @@ export function useLoginViewActions({ state, validation, queryClient, errorRunti
|
|
|
495
570
|
submitAuth,
|
|
496
571
|
requestOtpCode,
|
|
497
572
|
resendRegisterConfirmationEmail,
|
|
573
|
+
confirmRegistrationCode,
|
|
574
|
+
confirmRegistrationFromLink,
|
|
498
575
|
oauthProviderButtonLabel,
|
|
499
576
|
oauthProviderIcon,
|
|
500
577
|
startOAuthSignIn,
|
|
@@ -45,6 +45,8 @@ export function useLoginViewState({ placementContext }) {
|
|
|
45
45
|
const password = ref("");
|
|
46
46
|
const confirmPassword = ref("");
|
|
47
47
|
const otpCode = ref("");
|
|
48
|
+
// The first account's setup code, asked for while a production server has no account.
|
|
49
|
+
const setupCode = ref("");
|
|
48
50
|
const showPassword = ref(false);
|
|
49
51
|
const showConfirmPassword = ref(false);
|
|
50
52
|
const emailTouched = ref(false);
|
|
@@ -61,10 +63,15 @@ export function useLoginViewState({ placementContext }) {
|
|
|
61
63
|
const loading = ref(false);
|
|
62
64
|
const otpRequestPending = ref(false);
|
|
63
65
|
const registerConfirmationResendPending = ref(false);
|
|
66
|
+
const registrationConfirmPending = ref(false);
|
|
64
67
|
const errorMessage = ref("");
|
|
65
68
|
const infoMessage = ref("");
|
|
66
69
|
const pendingEmailConfirmationMessage = ref("");
|
|
67
70
|
const pendingEmailConfirmationAddress = ref("");
|
|
71
|
+
// In development without an email sender, the confirmation link itself.
|
|
72
|
+
const confirmationUrl = ref("");
|
|
73
|
+
// A confirmation code or link the person types or pastes.
|
|
74
|
+
const confirmationCode = ref("");
|
|
68
75
|
const invitationToken = ref(readWindowSearchParam("invitationToken") || readWindowSearchParam("inviteToken"));
|
|
69
76
|
|
|
70
77
|
const isLogin = computed(() => mode.value === LOGIN_MODE);
|
|
@@ -80,6 +87,8 @@ export function useLoginViewState({ placementContext }) {
|
|
|
80
87
|
const canUseOtp = computed(() => authCapabilities.value.features.otp.login === true);
|
|
81
88
|
const canUseOAuth = computed(() => authCapabilities.value.features.oauthLogin.enabled === true);
|
|
82
89
|
const canResendEmailConfirmation = computed(() => authCapabilities.value.features.emailConfirmation === true);
|
|
90
|
+
const canEnterConfirmationCode = computed(() => authCapabilities.value.features.emailConfirmationCode === true);
|
|
91
|
+
const needsFirstAccountSetupCode = computed(() => authCapabilities.value.features.firstAccountSetupCode === true);
|
|
83
92
|
const showRememberedAccount = computed(
|
|
84
93
|
() => (isLogin.value || isOtp.value) && useRememberedAccount.value && Boolean(rememberedAccount.value)
|
|
85
94
|
);
|
|
@@ -151,6 +160,7 @@ export function useLoginViewState({ placementContext }) {
|
|
|
151
160
|
password.value = "";
|
|
152
161
|
confirmPassword.value = "";
|
|
153
162
|
otpCode.value = "";
|
|
163
|
+
setupCode.value = "";
|
|
154
164
|
showPassword.value = false;
|
|
155
165
|
showConfirmPassword.value = false;
|
|
156
166
|
}
|
|
@@ -238,6 +248,8 @@ export function useLoginViewState({ placementContext }) {
|
|
|
238
248
|
if (resolvedMode !== EMAIL_CONFIRMATION_MODE) {
|
|
239
249
|
pendingEmailConfirmationAddress.value = "";
|
|
240
250
|
pendingEmailConfirmationMessage.value = "";
|
|
251
|
+
confirmationUrl.value = "";
|
|
252
|
+
confirmationCode.value = "";
|
|
241
253
|
}
|
|
242
254
|
clearTransientMessages();
|
|
243
255
|
resetTransientValidationState();
|
|
@@ -252,10 +264,11 @@ export function useLoginViewState({ placementContext }) {
|
|
|
252
264
|
}
|
|
253
265
|
}
|
|
254
266
|
|
|
255
|
-
function enterEmailConfirmationPendingState({ emailAddress = "", message = "" } = {}) {
|
|
267
|
+
function enterEmailConfirmationPendingState({ emailAddress = "", message = "", confirmationUrl: url = "" } = {}) {
|
|
256
268
|
switchMode(EMAIL_CONFIRMATION_MODE);
|
|
257
269
|
pendingEmailConfirmationAddress.value = normalizeEmailAddress(emailAddress);
|
|
258
270
|
pendingEmailConfirmationMessage.value = String(message || "").trim();
|
|
271
|
+
confirmationUrl.value = String(url || "").trim();
|
|
259
272
|
}
|
|
260
273
|
|
|
261
274
|
function goToMainScreen() {
|
|
@@ -268,6 +281,7 @@ export function useLoginViewState({ placementContext }) {
|
|
|
268
281
|
password,
|
|
269
282
|
confirmPassword,
|
|
270
283
|
otpCode,
|
|
284
|
+
setupCode,
|
|
271
285
|
showPassword,
|
|
272
286
|
showConfirmPassword,
|
|
273
287
|
emailTouched,
|
|
@@ -284,10 +298,13 @@ export function useLoginViewState({ placementContext }) {
|
|
|
284
298
|
loading,
|
|
285
299
|
otpRequestPending,
|
|
286
300
|
registerConfirmationResendPending,
|
|
301
|
+
registrationConfirmPending,
|
|
287
302
|
errorMessage,
|
|
288
303
|
infoMessage,
|
|
289
304
|
pendingEmailConfirmationMessage,
|
|
290
305
|
pendingEmailConfirmationAddress,
|
|
306
|
+
confirmationUrl,
|
|
307
|
+
confirmationCode,
|
|
291
308
|
invitationToken,
|
|
292
309
|
isLogin,
|
|
293
310
|
isRegister,
|
|
@@ -300,6 +317,8 @@ export function useLoginViewState({ placementContext }) {
|
|
|
300
317
|
canUseOtp,
|
|
301
318
|
canUseOAuth,
|
|
302
319
|
canResendEmailConfirmation,
|
|
320
|
+
canEnterConfirmationCode,
|
|
321
|
+
needsFirstAccountSetupCode,
|
|
303
322
|
showRememberedAccount,
|
|
304
323
|
rememberedAccountDisplayName,
|
|
305
324
|
rememberedAccountMaskedEmail,
|
|
@@ -112,6 +112,9 @@ export function useLoginViewValidation({ state }) {
|
|
|
112
112
|
if (emailErrorMessages.value.length > 0) {
|
|
113
113
|
return false;
|
|
114
114
|
}
|
|
115
|
+
if (state.isRegister.value && state.needsFirstAccountSetupCode.value && !String(state.setupCode.value || "").trim()) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
115
118
|
if (state.isRegister.value || state.isLogin.value) {
|
|
116
119
|
return passwordErrorMessages.value.length < 1 && confirmPasswordErrorMessages.value.length < 1;
|
|
117
120
|
}
|
|
@@ -40,6 +40,14 @@ function useLoginView() {
|
|
|
40
40
|
canUseOtp: state.canUseOtp,
|
|
41
41
|
canUseOAuth: state.canUseOAuth,
|
|
42
42
|
canResendEmailConfirmation: state.canResendEmailConfirmation,
|
|
43
|
+
canEnterConfirmationCode: state.canEnterConfirmationCode,
|
|
44
|
+
needsFirstAccountSetupCode: state.needsFirstAccountSetupCode,
|
|
45
|
+
setupCode: state.setupCode,
|
|
46
|
+
confirmationUrl: state.confirmationUrl,
|
|
47
|
+
confirmationCode: state.confirmationCode,
|
|
48
|
+
registrationConfirmPending: state.registrationConfirmPending,
|
|
49
|
+
confirmRegistrationCode: actions.confirmRegistrationCode,
|
|
50
|
+
confirmRegistrationFromLink: actions.confirmRegistrationFromLink,
|
|
43
51
|
emailConfirmationMessage: state.emailConfirmationMessage,
|
|
44
52
|
showRememberedAccount: state.showRememberedAccount,
|
|
45
53
|
switchMode: state.switchMode,
|
|
@@ -68,9 +68,9 @@ const placementContext = computed(() => {
|
|
|
68
68
|
<v-btn v-bind="props" variant="text" class="auth-profile-widget__activator text-none pl-1 pr-2">
|
|
69
69
|
<v-avatar size="32" color="primary" variant="tonal">
|
|
70
70
|
<v-img v-if="avatarUrl" :src="avatarUrl" cover />
|
|
71
|
-
<span v-else class="text-
|
|
71
|
+
<span v-else class="text-body-small font-weight-medium">{{ initials }}</span>
|
|
72
72
|
</v-avatar>
|
|
73
|
-
<span class="ml-2 d-none d-sm-inline text-body-
|
|
73
|
+
<span class="ml-2 d-none d-sm-inline text-body-medium">{{ displayName }}</span>
|
|
74
74
|
</v-btn>
|
|
75
75
|
</template>
|
|
76
76
|
|
|
@@ -82,9 +82,3 @@ const placementContext = computed(() => {
|
|
|
82
82
|
</v-list>
|
|
83
83
|
</v-menu>
|
|
84
84
|
</template>
|
|
85
|
-
|
|
86
|
-
<style scoped>
|
|
87
|
-
.auth-profile-widget__activator {
|
|
88
|
-
min-height: 48px;
|
|
89
|
-
}
|
|
90
|
-
</style>
|