Fix biometric auth TypeScript errors
- Add LOGIN_BIOMETRIC to AuditAction enum - Import AuditAction and EntityType in AuthService - Fix loginWithExternalAuth return type to match AuthResponse interface - Update biometric API client to use correct response structure - Update login page to access tokens from nested data structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ export enum AuditAction {
|
|||||||
DELETE = 'DELETE',
|
DELETE = 'DELETE',
|
||||||
EXPORT = 'EXPORT',
|
EXPORT = 'EXPORT',
|
||||||
LOGIN = 'LOGIN',
|
LOGIN = 'LOGIN',
|
||||||
|
LOGIN_BIOMETRIC = 'LOGIN_BIOMETRIC',
|
||||||
LOGOUT = 'LOGOUT',
|
LOGOUT = 'LOGOUT',
|
||||||
PASSWORD_RESET = 'PASSWORD_RESET',
|
PASSWORD_RESET = 'PASSWORD_RESET',
|
||||||
EMAIL_VERIFY = 'EMAIL_VERIFY',
|
EMAIL_VERIFY = 'EMAIL_VERIFY',
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { JwtService } from '@nestjs/jwt';
|
|||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import * as bcrypt from 'bcrypt';
|
import * as bcrypt from 'bcrypt';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
import { User, DeviceRegistry, RefreshToken, Family, FamilyMember } from '../../database/entities';
|
import { User, DeviceRegistry, RefreshToken, Family, FamilyMember, AuditAction, EntityType } from '../../database/entities';
|
||||||
import { RegisterDto } from './dto/register.dto';
|
import { RegisterDto } from './dto/register.dto';
|
||||||
import { LoginDto } from './dto/login.dto';
|
import { LoginDto } from './dto/login.dto';
|
||||||
import { RefreshTokenDto } from './dto/refresh-token.dto';
|
import { RefreshTokenDto } from './dto/refresh-token.dto';
|
||||||
@@ -433,30 +433,35 @@ export class AuthService {
|
|||||||
// Audit log for biometric login
|
// Audit log for biometric login
|
||||||
await this.auditService.log({
|
await this.auditService.log({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
action: 'LOGIN_BIOMETRIC',
|
action: AuditAction.LOGIN_BIOMETRIC,
|
||||||
resourceType: 'AUTH',
|
entityType: EntityType.USER,
|
||||||
resourceId: user.id,
|
entityId: user.id,
|
||||||
metadata: {
|
changes: {
|
||||||
deviceId: device.deviceFingerprint,
|
after: {
|
||||||
platform: device.platform,
|
deviceId: device.deviceFingerprint,
|
||||||
|
platform: device.platform,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accessToken: tokens.accessToken,
|
success: true,
|
||||||
refreshToken: tokens.refreshToken,
|
data: {
|
||||||
expiresIn: tokens.expiresIn,
|
tokens: {
|
||||||
user: {
|
accessToken: tokens.accessToken,
|
||||||
id: user.id,
|
refreshToken: tokens.refreshToken,
|
||||||
email: user.email,
|
expiresIn: tokens.expiresIn,
|
||||||
name: user.name,
|
},
|
||||||
phone: user.phone,
|
user: {
|
||||||
locale: user.locale,
|
id: user.id,
|
||||||
timezone: user.timezone,
|
email: user.email,
|
||||||
emailVerified: user.emailVerified,
|
name: user.name,
|
||||||
createdAt: user.createdAt,
|
locale: user.locale,
|
||||||
familyMemberships: user.familyMemberships,
|
emailVerified: user.emailVerified,
|
||||||
preferences: user.preferences,
|
preferences: user.preferences,
|
||||||
|
},
|
||||||
|
deviceRegistered: true,
|
||||||
|
deviceTrusted: device.trusted,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export default function LoginPage() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Store tokens and navigate
|
// Store tokens and navigate
|
||||||
tokenStorage.setTokens(result.tokens.accessToken, result.tokens.refreshToken);
|
tokenStorage.setTokens(result.data.tokens.accessToken, result.data.tokens.refreshToken);
|
||||||
router.push('/');
|
router.push('/');
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error('Biometric login failed:', err);
|
console.error('Biometric login failed:', err);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export const biometricApi = {
|
|||||||
response: any,
|
response: any,
|
||||||
email?: string,
|
email?: string,
|
||||||
deviceInfo?: { deviceId: string; platform: string }
|
deviceInfo?: { deviceId: string; platform: string }
|
||||||
): Promise<{ success: boolean; message: string; user: any; tokens: any }> {
|
): Promise<{ success: boolean; data: { user: any; tokens: any; deviceRegistered: boolean; deviceTrusted: boolean } }> {
|
||||||
const verifyResponse = await axios.post(
|
const verifyResponse = await axios.post(
|
||||||
`${API_BASE_URL}/api/v1/auth/biometric/authenticate/verify`,
|
`${API_BASE_URL}/api/v1/auth/biometric/authenticate/verify`,
|
||||||
{ response, email, deviceInfo }
|
{ response, email, deviceInfo }
|
||||||
|
|||||||
Reference in New Issue
Block a user