Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(standalone/setup): dedicated handling for wrong password
Elian Doran310035be1baf
diff --git a/apps/client/src/setup.tsx b/apps/client/src/setup.tsxindex cca7f7239c..45f9b6572c 100644--- a/apps/client/src/setup.tsx+++ b/apps/client/src/setup.tsx@@ -224,6 +224,7 @@ function SyncFromServer({ setState }: { setState: (state: State) => void }) {const [ syncProxy, setSyncProxy ] = useState("");const [ error, setError ] = useState<string | null>(null);const [ errorId, setErrorId ] = useState(0);+ const [ isWrongPassword, setIsWrongPassword ] = useState(false);const isValid = syncServerHost.trim() !== "" && password !== "";function raiseError(message: string) {@@ -241,6 +242,8 @@ function SyncFromServer({ setState }: { setState: (state: State) => void }) {if (resp.result === "success") {setState("syncInProgress");+ } else if (resp.error.includes("Incorrect password")) {+ setIsWrongPassword(true);} else {raiseError(t("setup.sync-failed", { message: resp.error }));}@@ -267,8 +270,15 @@ function SyncFromServer({ setState }: { setState: (state: State) => void }) {<FormTextBox placeholder={t("setup.server-host-placeholder")} currentValue={syncServerHost} onChange={setSyncServerHost} required /></FormGroup>- <FormGroup label={t("setup.server-password")} name="serverPassword">- <FormTextBox type="password" currentValue={password} onChange={setPassword} required />+ <FormGroup+ label={t("setup.server-password")} name="serverPassword"+ error={isWrongPassword ? t("setup.wrong-password") : undefined}+ >+ <FormTextBox+ type="password"+ currentValue={password} onChange={setPassword}+ required+ /></FormGroup><Collapsible title={t("setup.advanced-options")} initiallyExpanded={false}>diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 5b0a3ec086..60cdbc0132 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2271,6 +2271,7 @@"proxy-server": "Proxy server (optional)","proxy-server-placeholder": "https://<hostname>:<port>","proxy-instruction": "If you leave proxy setting blank, system proxy will be used.",- "dismiss-error": "Dismiss error"+ "dismiss-error": "Dismiss error",+ "wrong-password": "Incorrect password. Please try again."}}diff --git a/apps/client/src/widgets/react/FormGroup.tsx b/apps/client/src/widgets/react/FormGroup.tsxindex 701b53c234..7ecb24d545 100644--- a/apps/client/src/widgets/react/FormGroup.tsx+++ b/apps/client/src/widgets/react/FormGroup.tsx@@ -1,5 +1,6 @@import { cloneElement, ComponentChildren, RefObject, VNode } from "preact";import { CSSProperties } from "preact/compat";+import { useUniqueName } from "./hooks";interface FormGroupProps {@@ -8,6 +9,7 @@ interface FormGroupProps {label?: string;title?: string;className?: string;+ error?: string;// eslint-disable-next-line @typescript-eslint/no-explicit-anychildren: VNode<any>;description?: string | ComponentChildren;@@ -15,7 +17,7 @@ interface FormGroupProps {style?: CSSProperties;}-export default function FormGroup({ name, label, title, className, children, description, labelRef, disabled, style }: FormGroupProps) {+export default function FormGroup({ name, label, title, className, children, description, labelRef, disabled, style, error }: FormGroupProps) {const id = useUniqueName(name);const childWithId = cloneElement(children, { id });@@ -26,6 +28,7 @@ export default function FormGroup({ name, label, title, className, children, des{childWithId}+ {error && <div><small className="form-text text-danger">{error}</small></div>}{description && <div><small className="form-text">{description}</small></div>}</div>);@@ -41,4 +44,4 @@ export function FormMultiGroup({ label, children }: { label: string, children: C{children}</div>);-}\ No newline at end of file+}