This commit is contained in:
Baobhan Sith
2025-05-08 15:58:31 +08:00
parent 20a741e314
commit 0972813bf7
2 changed files with 15 additions and 11 deletions
@@ -267,7 +267,6 @@ export class PasskeyService {
async listPasskeysByUserId(userId: number): Promise<Partial<Passkey>[]> { async listPasskeysByUserId(userId: number): Promise<Partial<Passkey>[]> {
const passkeys = await this.passkeyRepo.getPasskeysByUserId(userId); const passkeys = await this.passkeyRepo.getPasskeysByUserId(userId);
console.log(`[PasskeyService] Passkeys for user ${userId} before mapping to partial:`, JSON.stringify(passkeys, null, 2));
// 只返回部分信息以避免泄露敏感数据 // 只返回部分信息以避免泄露敏感数据
return passkeys.map(pk => ({ return passkeys.map(pk => ({
credential_id: pk.credential_id, credential_id: pk.credential_id,
+15 -10
View File
@@ -1247,19 +1247,24 @@ const handleDeletePasskey = async (credentialID: string) => {
const formatDate = (dateInput: string | number | Date | undefined): string => { const formatDate = (dateInput: string | number | Date | undefined): string => {
if (!dateInput) return t('statusMonitor.notAvailable'); if (!dateInput) return t('statusMonitor.notAvailable');
try { try {
const date = new Date(dateInput); // If dateInput is a number, assume it's a Unix timestamp in seconds
// Check if date is valid if (typeof dateInput === 'number') {
if (isNaN(date.getTime())) { const dateFromSeconds = new Date(dateInput * 1000);
// Try parsing as seconds if it's a number (common for Unix timestamps) if (!isNaN(dateFromSeconds.getTime())) {
if (typeof dateInput === 'number') { return dateFromSeconds.toLocaleString();
const dateFromSeconds = new Date(dateInput * 1000);
if (!isNaN(dateFromSeconds.getTime())) {
return dateFromSeconds.toLocaleString();
}
} }
// If conversion from seconds still results in an invalid date, return N/A
return t('statusMonitor.notAvailable'); return t('statusMonitor.notAvailable');
} }
return date.toLocaleString();
// If dateInput is a string or Date object, try to parse it directly
const date = new Date(dateInput);
if (!isNaN(date.getTime())) {
return date.toLocaleString();
}
// If all parsing fails
return t('statusMonitor.notAvailable');
} catch (e) { } catch (e) {
console.error("Error formatting date:", e); console.error("Error formatting date:", e);
return t('statusMonitor.notAvailable'); return t('statusMonitor.notAvailable');