Add fingerprint (local_auth) session + 3-min inactivity timeout (default), activity resets timer, settings: biometric toggle + timeout picker

This commit is contained in:
cania
2026-08-12 20:13:57 +02:00
parent 9c3fe4f8e9
commit 68fca2c2c6
12 changed files with 305 additions and 52 deletions

View File

@@ -5,7 +5,8 @@ import 'package:login_vault_app/auth_service.dart';
import 'package:login_vault_app/dashboard_screen.dart';
import 'package:login_vault_app/theme_provider.dart';
/// First-launch screen: register with email+password, or with Google.
/// First screen: register, or (if registered) re-authenticate.
/// If a valid session exists, skip straight to the Dashboard.
class AuthScreen extends StatefulWidget {
final AuthService auth;
const AuthScreen({super.key, required this.auth});
@@ -17,12 +18,29 @@ class AuthScreen extends StatefulWidget {
class _AuthScreenState extends State<AuthScreen> {
final _emailCtrl = TextEditingController();
final _passCtrl = TextEditingController();
bool _isLogin = true; // toggle register/login
bool _isLogin = true;
bool _busy = false;
String? _error;
@override
void initState() {
super.initState();
_trySilentAuth();
}
/// On open: if a valid session is present, go straight to Dashboard.
Future<void> _trySilentAuth() async {
final timeout = await widget.auth.getTimeoutMinutes();
final valid = await widget.auth.hasValidSession(timeout);
if (valid && mounted) {
final email = await widget.auth.getEmail() ?? '';
_goToDashboard(email);
}
}
void _goToDashboard(String email) {
if (!mounted) return;
widget.auth.openSession(); // refresh session timestamp
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (_) => DashboardScreen(