Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Fix bug with birthdate parsing (#771)

Leendert de Borstb0203882f34e
diff --git a/mobile-app/app/(tabs)/(credentials)/[id].tsx b/mobile-app/app/(tabs)/(credentials)/[id].tsx
index 3cf15eac7..fb18c288e 100644
--- a/mobile-app/app/(tabs)/(credentials)/[id].tsx
+++ b/mobile-app/app/(tabs)/(credentials)/[id].tsx
@@ -28,15 +28,6 @@ export default function CredentialDetailsScreen() {
try {
const cred = await dbContext.sqliteClient!.getCredentialById(id as string);
- if (cred?.Alias?.BirthDate) {
- // Convert the string date to a Date object
- const date = new Date(cred.Alias.BirthDate);
- if (!isNaN(date.getTime())) {
- cred.Alias.BirthDate = date;
- } else {
- cred.Alias.BirthDate = undefined;
- }
- }
setCredential(cred);
} catch (err) {
console.error('Error loading credential:', err);
diff --git a/mobile-app/components/credentialDetails/AliasDetails.tsx b/mobile-app/components/credentialDetails/AliasDetails.tsx
index 12194306a..195b345fa 100644
--- a/mobile-app/components/credentialDetails/AliasDetails.tsx
+++ b/mobile-app/components/credentialDetails/AliasDetails.tsx
@@ -11,7 +11,14 @@ export const AliasDetails: React.FC<AliasDetailsProps> = ({ credential }) => {
const hasName = Boolean(credential.Alias?.FirstName?.trim() || credential.Alias?.LastName?.trim());
const fullName = [credential.Alias?.FirstName, credential.Alias?.LastName].filter(Boolean).join(' ');
- if (!hasName && !credential.Alias?.NickName && !credential.Alias?.BirthDate) {
+ const hasValidBirthDate = credential.Alias?.BirthDate ? (() => {
+ const date = new Date(credential.Alias.BirthDate);
+ return !isNaN(date.getTime()) &&
+ date.getFullYear() > 1 &&
+ date.getFullYear() < 9999;
+ })() : false;
+
+ if (!hasName && !credential.Alias?.NickName && !hasValidBirthDate) {
return null;
}
@@ -42,10 +49,10 @@ export const AliasDetails: React.FC<AliasDetailsProps> = ({ credential }) => {
value={credential.Alias.NickName}
/>
)}
- {credential.Alias?.BirthDate && !isNaN(credential.Alias.BirthDate.getTime()) && credential.Alias.BirthDate.getTime() !== new Date(0).getTime() && (
+ {hasValidBirthDate && (
<FormInputCopyToClipboard
label="Birth Date"
- value={credential.Alias.BirthDate.toISOString().split('T')[0]}
+ value={credential.Alias.BirthDate.split('T')[0]}
/>
)}
</ThemedView>