Skip to content

An open-source, self-hosted system for apps built with web technologies.

The first screen says it creates an account, and asks for the password twice

zohayrslilehbdc7b8e302f4
diff --git a/source/client/view/structure/authentication/credentials-form.tsx b/source/client/view/structure/authentication/credentials-form.tsx
index c27ac80..7a94348 100644
--- a/source/client/view/structure/authentication/credentials-form.tsx
+++ b/source/client/view/structure/authentication/credentials-form.tsx
@@ -8,13 +8,17 @@ import { useId, useState, type SyntheticEvent } from "react"
import logo from "@/assets/logo.png"
import { name, version } from "@/source/identity"
-/** The common username-and-password welcome for sign-up and sign-in: the first thing a System shows. */
-export default function CredentialsForm({ title, description, submitLabel, passwordAutocomplete, requirements, error, pending, onEdit, onSubmit }: CredentialsFormProps) {
+/**
+ * The common username-and-password welcome for sign-up and sign-in: the first thing a System shows.
+ * Creating an account asks for the password twice, which also tells it apart from signing in.
+ */
+export default function CredentialsForm({ title, description, submitLabel, passwordAutocomplete, confirmPassword = false, requirements, error, pending, onEdit, onSubmit }: CredentialsFormProps) {
const reducedMotion = useReducedMotion()
const { spacing } = useAppearance()
const transaction = useTiming()("change")
const [password, setPassword] = useState("")
+ const [mismatch, setMismatch] = useState(false)
const titleId = useId()
const passwordReady = requirements === undefined || [...password].length >= requirements.password.minimumLength
@@ -26,6 +30,14 @@ export default function CredentialsForm({ title, description, submitLabel, passw
const data = new FormData(event.currentTarget)
+ // The two passwords must agree before anything is sent.
+ if (confirmPassword && data.get("password") !== data.get("confirm")) {
+
+ setMismatch(true)
+
+ return
+ }
+
onSubmit(String(data.get("username") ?? ""), String(data.get("password") ?? ""))
}
@@ -115,11 +127,25 @@ export default function CredentialsForm({ title, description, submitLabel, passw
// This controls registration readiness only; Authentication
// remains the authority for accepting the submitted value.
setPassword(value)
+ setMismatch(false)
onEdit?.()
}}
description={requirements ? `Use at least ${requirements.password.minimumLength} characters.` : undefined}
/>
+ {confirmPassword && <Input
+ label="Confirm password"
+ size="large"
+ name="confirm"
+ type="password"
+ autoComplete="new-password"
+ required
+ disabled={pending}
+ invalid={mismatch}
+ errorMessage={mismatch ? "The passwords do not match." : undefined}
+ onChange={() => setMismatch(false)}
+ />}
+
</div>
{(error?.target === "credentials" || error?.target === "form") && <Alert className="text-sm">{error.message}</Alert>}
@@ -165,6 +191,9 @@ interface CredentialsFormProps {
passwordAutocomplete: "current-password" | "new-password"
+ /** Asks for the password a second time, as creating an account does. */
+ confirmPassword?: boolean
+
requirements?: AuthenticationState["requirements"]
error?: CredentialsError | null
diff --git a/source/client/view/structure/authentication/sign-up.tsx b/source/client/view/structure/authentication/sign-up.tsx
index 79f78f0..566a728 100644
--- a/source/client/view/structure/authentication/sign-up.tsx
+++ b/source/client/view/structure/authentication/sign-up.tsx
@@ -18,14 +18,16 @@ export default function SignUp({ state, onClosed }: SignUpProps) {
return <CredentialsForm
- title="Fresh soil."
+ title="Create your account"
- description="This System is new and has no owner yet. Create the owner account to make it yours."
+ description="This System is new and has no owner yet. Choose any username and password to become its owner."
- submitLabel="Create owner account"
+ submitLabel="Create account"
passwordAutocomplete="new-password"
+ confirmPassword
+
requirements={state.requirements}
error={signUp.exception ? {