Files
TimeTracker/mobile/lib/utils/auth/auth_service.dart
T
Dries Peeters e9049ef923 fix(mobile): add missing Flutter app source files to fix build errors
- Add lib/main.dart entry point with proper routing setup
- Create Timer model (lib/data/models/timer.dart) with toJson support
- Enhance ApiClient with all required API methods:
  * Timer operations (getTimerStatus, startTimer, stopTimer)
  * Time entry operations (CRUD)
  * Project and task operations
- Add toJson() methods to TimeEntry and Timer models
- Fix splash screen auth check to use async methods properly
- Add missing provider methods (getElapsedTime, checkTimerStatus, loadTimeEntries)
- Update .gitignore to allow tracking mobile/lib/ directory

Fixes build error: 'Target file lib/main.dart not found' when running
flutter build apk --release or flutter build ios --release
2026-01-13 13:43:56 +01:00

28 lines
754 B
Dart

import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class AuthService {
static const _storage = FlutterSecureStorage();
static const String _keyApiToken = 'api_token';
// Store API token securely
static Future<void> storeToken(String token) async {
await _storage.write(key: _keyApiToken, value: token);
}
// Retrieve API token
static Future<String?> getToken() async {
return await _storage.read(key: _keyApiToken);
}
// Delete API token (logout)
static Future<void> deleteToken() async {
await _storage.delete(key: _keyApiToken);
}
// Check if token exists
static Future<bool> hasToken() async {
final token = await getToken();
return token != null && token.isNotEmpty;
}
}