From 26d94c4ba7dd12cfa433d0c037f3bba8f73995f4 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 30 Dec 2022 10:42:15 -0300
Subject: add login username validation & prevent safari to capitalize

---
 packages/demobank-ui/src/pages/LoginForm.tsx | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'packages/demobank-ui/src/pages/LoginForm.tsx')

diff --git a/packages/demobank-ui/src/pages/LoginForm.tsx b/packages/demobank-ui/src/pages/LoginForm.tsx
index dd0364d6e..1fbba357b 100644
--- a/packages/demobank-ui/src/pages/LoginForm.tsx
+++ b/packages/demobank-ui/src/pages/LoginForm.tsx
@@ -23,6 +23,7 @@ import { BackendStateHandler } from "../hooks/backend.js";
 import { bankUiSettings } from "../settings.js";
 import { getBankBackendBaseUrl, undefinedIfEmpty } from "../utils.js";
 import { ShowInputErrorLabel } from "./ShowInputErrorLabel.js";
+import { USERNAME_REGEX } from "./RegistrationPage.js";
 
 /**
  * Collect and submit login data.
@@ -38,7 +39,11 @@ export function LoginForm(): VNode {
   }, []);
 
   const errors = undefinedIfEmpty({
-    username: !username ? i18n.str`Missing username` : undefined,
+    username: !username
+      ? i18n.str`Missing username`
+      : !USERNAME_REGEX.test(username)
+      ? i18n.str`Use only letter and numbers starting with a lower case letter`
+      : undefined,
     password: !password ? i18n.str`Missing password` : undefined,
   });
 
@@ -50,6 +55,9 @@ export function LoginForm(): VNode {
         onSubmit={(e) => {
           e.preventDefault();
         }}
+        autoCapitalize="none"
+        autoCorrect="off"
+        autoComplete="off"
       >
         <div class="pure-form">
           <h2>{i18n.str`Please login!`}</h2>
-- 
cgit v1.2.3

