This repository has been archived on 2026-06-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FabledApp/lib/data/api/auth_api.dart
T
bvandeusen 4da36aa31d Initial commit: Fabled Android app
Flutter Android client for FabledAssistant with:
- Session-cookie auth via persistent cookie jar (Dio + cookie_jar)
- OAuth/SSO login via in-app WebView (flutter_inappwebview)
- Notes: list, detail (markdown render), create/edit
- Tasks: list with status tabs, create/edit with priority
- Chat: SSE streaming bubbles, conversation management
- Quick Capture FAB for rapid note/task creation
- Settings screen (change server URL, logout)
- Android home screen widget → opens chat
- Riverpod state management, go_router navigation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 21:28:53 -05:00

51 lines
1.1 KiB
Dart

import 'package:dio/dio.dart';
import '../../core/exceptions.dart';
import 'api_client.dart';
class AuthApi {
final Dio _dio;
const AuthApi(this._dio);
Future<void> login(String username, String password) async {
try {
await _dio.post('/api/auth/login', data: {
'username': username,
'password': password,
});
} on DioException catch (e) {
if (e.response?.statusCode == 401) {
throw const AuthException('Invalid username or password.');
}
throw dioToApp(e);
}
}
Future<void> logout() async {
try {
await _dio.post('/api/auth/logout');
} on DioException catch (e) {
throw dioToApp(e);
}
}
Future<bool> verify() async {
try {
await _dio.get('/api/auth/me');
return true;
} on DioException catch (e) {
if (e.response?.statusCode == 401) return false;
throw dioToApp(e);
}
}
Future<Map<String, dynamic>> getStatus() async {
try {
final response = await _dio.get('/api/auth/status');
return response.data as Map<String, dynamic>;
} on DioException catch (e) {
throw dioToApp(e);
}
}
}