A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: don't let user signup if all pwd rqmnts aren't met
thecodrr53d37bc625a8
diff --git a/apps/web/src/components/dialogs/signupdialog.js b/apps/web/src/components/dialogs/signupdialog.jsindex 5577b2d35..e18f5e061 100644--- a/apps/web/src/components/dialogs/signupdialog.js+++ b/apps/web/src/components/dialogs/signupdialog.js@@ -46,6 +46,11 @@ function SignUpDialog(props) {as="form"onSubmit={(e) => {e.preventDefault();+ if (error) {+ setError("Please resolve all errors before continuing.");+ return;+ }+const data = requiredValues.reduce((prev, curr) => {prev[curr] = e.target[curr].value;return prev;@@ -87,9 +92,14 @@ function SignUpDialog(props) {type="password"autoComplete="new-password"validatePassword+ onError={setError}sx={{ mt: 1 }}/>- {error && <Text variant="error">{error}</Text>}+ {error && typeof error === "string" && (+ <Text variant="error" fontSize="body" mt={2}>+ {error}+ </Text>+ )}</Box></Dialog>);diff --git a/apps/web/src/components/field/index.js b/apps/web/src/components/field/index.jsindex 29c01e355..faba521ac 100644--- a/apps/web/src/components/field/index.js+++ b/apps/web/src/components/field/index.js@@ -45,6 +45,7 @@ function Field(props) {defaultValue,placeholder,validatePassword,+ onError,} = props;const [isPasswordVisible, setIsPasswordVisible] = useState(false);const [rules, setRules] = useState(passwordValidationRules);@@ -81,11 +82,13 @@ function Field(props) {onChange={(e) => {if (validatePassword) {const value = e.target.value;- setRules((rules) =>- rules.map((rule) => {- return { ...rule, isValid: rule.validate(value) };- })- );+ const mapped = rules.map((rule) => {+ return { ...rule, isValid: rule.validate(value) };+ });+ if (onError) {+ onError(mapped.some((m) => !m.isValid));+ }+ setRules(mapped);}if (onChange) onChange(e);}}