feat: Phase 1 complete — Matrix login, rooms, chat, profile
- Direct m.login.password auth against matrix.m8chat.au - Room list with unread badges, last message, timestamps - Chat timeline (text, images, files, replies, reactions) - Profile screen with expandable Notifications and Security sections - Olm E2EE initialisation (web WASM bootstrap) - Global error handler preventing Matrix SDK crashes - GoRouter with refreshListenable (no recreation on auth change) - Feature-first clean architecture: Riverpod + GoRouter + Drift - Deployed to https://app2.m8chat.au Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
41
lib/features/auth/domain/auth_failure.dart
Normal file
41
lib/features/auth/domain/auth_failure.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
// Version: 1.0.0 | Created: 2026-04-01
|
||||
// Typed failure hierarchy for authentication errors.
|
||||
// UI maps these to human-readable messages — never expose raw exception text.
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'auth_failure.freezed.dart';
|
||||
|
||||
/// All ways authentication can fail.
|
||||
@freezed
|
||||
sealed class AuthFailure with _$AuthFailure {
|
||||
/// Username or password was incorrect.
|
||||
const factory AuthFailure.invalidCredentials() = InvalidCredentials;
|
||||
|
||||
/// Could not reach the Matrix homeserver.
|
||||
const factory AuthFailure.networkError({String? message}) = NetworkError;
|
||||
|
||||
/// The server returned an unexpected response.
|
||||
const factory AuthFailure.serverError({int? statusCode, String? message}) =
|
||||
ServerError;
|
||||
|
||||
/// User's account has been disabled or deactivated.
|
||||
const factory AuthFailure.accountDisabled() = AccountDisabled;
|
||||
|
||||
/// An unexpected error that doesn't fit the categories above.
|
||||
const factory AuthFailure.unknown({required String message}) = UnknownFailure;
|
||||
}
|
||||
|
||||
/// Maps an [AuthFailure] to a user-facing string (Australian English).
|
||||
extension AuthFailureMessage on AuthFailure {
|
||||
String get userMessage => switch (this) {
|
||||
InvalidCredentials() => 'Incorrect username or password. Please try again.',
|
||||
NetworkError() =>
|
||||
'Could not connect to the server. Check your internet connection and try again.',
|
||||
ServerError(statusCode: final code) =>
|
||||
'The server returned an error${code != null ? ' (code $code)' : ''}. Please try again shortly.',
|
||||
AccountDisabled() =>
|
||||
'Your account has been disabled. Please contact the administrator.',
|
||||
UnknownFailure(message: final msg) => 'Something went wrong: $msg',
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user