Skip to content

Commit 901e1bf

Browse files
committed
refactor(profile): show account joined date in header metadata instead of email
1 parent 82d114a commit 901e1bf

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

src/app/features/profile/components/user-profile-security/user-profile-security.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ <h2>User Profile & Security</h2>
1010
{{ userDisplayName() }}
1111
</span>
1212
<span class="meta-pill">
13-
<i class="pi pi-envelope"></i>
14-
{{ userEmail() }}
13+
<i class="pi pi-calendar"></i>
14+
Joined {{ accountCreatedAt() ? (accountCreatedAt() | date:'mediumDate') : 'Unknown' }}
1515
</span>
1616
<span class="meta-pill" *ngIf="isDebugSession">
1717
<i class="pi pi-eye"></i>

src/app/features/profile/components/user-profile-security/user-profile-security.component.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ export class UserProfileSecurityComponent {
5151
return typeof email === 'string' && email.trim().length > 0 ? email : 'Not provided';
5252
});
5353

54+
readonly accountCreatedAt = computed(() => {
55+
const claims = this.claims();
56+
const candidateKeys = ['created_at', 'account_created_at', 'registered_at', 'iat'];
57+
58+
for (const key of candidateKeys) {
59+
const parsed = this.parseDateClaim(claims[key]);
60+
if (parsed) {
61+
return parsed;
62+
}
63+
}
64+
65+
return null;
66+
});
67+
5468
readonly scopes = computed(() => {
5569
const scope = this.session()?.scope ?? '';
5670
return scope
@@ -139,4 +153,33 @@ export class UserProfileSecurityComponent {
139153

140154
return String(value);
141155
}
156+
157+
private parseDateClaim(value: unknown): Date | null {
158+
if (value === null || value === undefined) {
159+
return null;
160+
}
161+
162+
if (typeof value === 'number' && Number.isFinite(value)) {
163+
return new Date(value < 10_000_000_000 ? value * 1000 : value);
164+
}
165+
166+
if (typeof value === 'string') {
167+
const trimmed = value.trim();
168+
if (!trimmed) {
169+
return null;
170+
}
171+
172+
if (/^\d+$/.test(trimmed)) {
173+
const numericValue = Number(trimmed);
174+
if (Number.isFinite(numericValue)) {
175+
return new Date(numericValue < 10_000_000_000 ? numericValue * 1000 : numericValue);
176+
}
177+
}
178+
179+
const parsedDate = new Date(trimmed);
180+
return Number.isNaN(parsedDate.getTime()) ? null : parsedDate;
181+
}
182+
183+
return null;
184+
}
142185
}

0 commit comments

Comments
 (0)