Change PIN to 1451
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../services/auth_service.dart';
|
||||
|
||||
class AuthProvider with ChangeNotifier {
|
||||
final AuthService _authService = AuthService();
|
||||
|
||||
bool _isLoading = false;
|
||||
String? _error;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
bool get isAuthenticated => _authService.isAuthenticated;
|
||||
String? get token => _authService.token;
|
||||
String? get username => _authService.username;
|
||||
String? get error => _error;
|
||||
|
||||
Future<void> init() async {
|
||||
_isLoading = true;
|
||||
notifyListeners();
|
||||
|
||||
await _authService.loadStoredAuth();
|
||||
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<bool> login(String username, String password) async {
|
||||
_isLoading = true;
|
||||
_error = null;
|
||||
notifyListeners();
|
||||
|
||||
final success = await _authService.login(username, password);
|
||||
|
||||
if (!success) {
|
||||
_error = _authService.lastError ?? 'Login failed';
|
||||
}
|
||||
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
await _authService.logout();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void clearError() {
|
||||
_error = null;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user