mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-24 15:20:52 -05:00
e9049ef923
- 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
28 lines
754 B
Dart
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;
|
|
}
|
|
}
|