Refactor registration and login and improve routing
Changes:
- Improve registration and login pages
- Extract Home component from App.tsx file into its own
- Make Home component display registration or login
- Extract routes from App component and refactor routing
GitLab: #12
Change-Id: I68b01890781308282072b6dcf5e6df0d54837b4a
diff --git a/client/src/utils/auth.ts b/client/src/utils/auth.ts
index 8d4d863..98ecdba 100644
--- a/client/src/utils/auth.ts
+++ b/client/src/utils/auth.ts
@@ -29,9 +29,13 @@
export interface PasswordCheckResult {
strong: boolean;
- value: string;
+ valueCode: StrengthValueCode;
}
+export type StrengthValueCode = 'default' | 'too_weak' | 'weak' | 'medium' | 'strong';
+
+const idToStrengthValueCode: StrengthValueCode[] = ['too_weak', 'weak', 'medium', 'strong'];
+
// TODO: Find a way to do it differently or remove this check from account creation.
// It doesn't work if the server has secured this path, so I tweaked the server for test.
// The tweak is to remove secured of apiRouter middleware in the server (app.ts).
@@ -41,8 +45,10 @@
if (response.status === HttpStatusCode.Ok) {
const data: LookupResolveValue = await response.json();
return data.name === name;
+ } else if (response.status === HttpStatusCode.NotFound) {
+ return false;
}
- return false;
+ return true;
} catch (err) {
return true;
}
@@ -53,7 +59,7 @@
const checkResult: PasswordCheckResult = {
strong: strengthResult.id === PasswordStrength.Strong.valueOf(),
- value: strengthResult.value,
+ valueCode: idToStrengthValueCode[strengthResult.id] ?? 'default',
};
return checkResult;