fix(01-02): resolve compilation errors in auth models
- Fixed import path in AuthRepository to reach core errors - Updated AuthUser.fromSupabase() to handle DateTime parsing safely - Added UnknownAuthException for fallback error handling - Fixed null-aware operators in AuthUser model - All authentication files now compile without errors
This commit is contained in:
@@ -146,6 +146,19 @@ class AuthDisabledException extends AuthException {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Exception thrown for unknown authentication errors
|
||||||
|
class UnknownAuthException extends AuthException {
|
||||||
|
const UnknownAuthException({
|
||||||
|
String message = 'An unknown authentication error occurred',
|
||||||
|
String? code,
|
||||||
|
dynamic originalError,
|
||||||
|
}) : super(
|
||||||
|
message: message,
|
||||||
|
code: code ?? 'UNKNOWN_ERROR',
|
||||||
|
originalError: originalError,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Utility class for converting Supabase errors to custom exceptions
|
/// Utility class for converting Supabase errors to custom exceptions
|
||||||
///
|
///
|
||||||
/// Provides a centralized way to map Supabase error responses
|
/// Provides a centralized way to map Supabase error responses
|
||||||
@@ -263,7 +276,7 @@ class AuthExceptionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fallback for unknown errors
|
// Fallback for unknown errors
|
||||||
return AuthException(
|
return UnknownAuthException(
|
||||||
message: _extractUserFriendlyMessage(errorMessage) ?? 'Authentication failed',
|
message: _extractUserFriendlyMessage(errorMessage) ?? 'Authentication failed',
|
||||||
code: errorCode,
|
code: errorCode,
|
||||||
originalError: error,
|
originalError: error,
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ class AuthUser {
|
|||||||
return AuthUser(
|
return AuthUser(
|
||||||
id: user.id,
|
id: user.id,
|
||||||
email: user.email ?? '',
|
email: user.email ?? '',
|
||||||
createdAt: user.createdAt ?? DateTime.now(),
|
createdAt: DateTime.tryParse(user.createdAt.toString()) ?? DateTime.now(),
|
||||||
emailVerified: user.emailConfirmedAt != null,
|
emailVerified: user.emailConfirmedAt != null,
|
||||||
displayName: user.userMetadata?['display_name'] as String?,
|
displayName: user.userMetadata?['display_name'] as String?,
|
||||||
avatarUrl: user.userMetadata?['avatar_url'] as String?,
|
avatarUrl: user.userMetadata?['avatar_url'] as String?,
|
||||||
lastSignInAt: user.lastSignInAt,
|
lastSignInAt: DateTime.tryParse(user.lastSignInAt.toString()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import '../../data/models/auth_user.dart';
|
import '../../data/models/auth_user.dart';
|
||||||
import '../../../core/errors/auth_exceptions.dart';
|
import '../../../../core/errors/auth_exceptions.dart';
|
||||||
|
|
||||||
/// Authentication repository interface defining all authentication operations.
|
/// Authentication repository interface defining all authentication operations.
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user