File tree Expand file tree Collapse file tree
quantus_sdk/lib/src/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,18 +38,19 @@ class _AuthenticationSettingsScreenState extends State<AuthenticationSettingsScr
3838 bool _isDeviceAuthEnabled = false ;
3939 bool _isLoading = true ;
4040 String _biometricDescription = 'Use Device Authentication' ;
41- int _authTimeout = 0 ;
41+ late int _authTimeout;
4242
4343 @override
4444 void initState () {
4545 super .initState ();
46+ _authTimeout = _localAuthService.getAuthTimeoutMinutes ();
4647 _loadAuthenticationSettings ();
4748 }
4849
4950 Future <void > _loadAuthenticationSettings () async {
5051 try {
5152 final isEnabled = _localAuthService.isLocalAuthEnabled ();
52- final authTimeout = _localAuthService.getAuthTimeout ();
53+ final authTimeout = _localAuthService.getAuthTimeoutMinutes ();
5354 final isAvailable = await _localAuthService.isBiometricAvailable ();
5455 final description = await _localAuthService.getBiometricDescription ();
5556
@@ -143,7 +144,7 @@ class _AuthenticationSettingsScreenState extends State<AuthenticationSettingsScr
143144 }
144145
145146 void _setAuthTimeout (int timeoutDurationInMinutes) {
146- _localAuthService.setAuthTimeout (timeoutDurationInMinutes);
147+ _localAuthService.setAuthTimeoutMinutes (timeoutDurationInMinutes);
147148 setState (() {
148149 _authTimeout = timeoutDurationInMinutes;
149150 });
Original file line number Diff line number Diff line change @@ -55,11 +55,11 @@ class LocalAuthService {
5555 _settingsService.setAuthEnabled (enabled);
5656 }
5757
58- int getAuthTimeout () {
59- return _settingsService.getAuthTimeout () ?? 0 ;
58+ int getAuthTimeoutMinutes () {
59+ return _settingsService.getAuthTimeout () ?? 1 ;
6060 }
6161
62- void setAuthTimeout (int timeoutDurationInMinutes) {
62+ void setAuthTimeoutMinutes (int timeoutDurationInMinutes) {
6363 return _settingsService.setAuthTimeout (timeoutDurationInMinutes);
6464 }
6565
@@ -175,9 +175,10 @@ class LocalAuthService {
175175 if (! isEnabled) return false ;
176176
177177 final DateTime ? lastAuthTime = _settingsService.getLastSuccessfulAuthTime ();
178+
178179 if (lastAuthTime == null ) return true ;
179180
180- final int timeoutDurationInMinutes = _settingsService. getAuthTimeout () ?? 5 ;
181+ final int timeoutDurationInMinutes = getAuthTimeoutMinutes () ;
181182
182183 final Duration authTimeout = Duration (minutes: timeoutDurationInMinutes);
183184
@@ -186,7 +187,8 @@ class LocalAuthService {
186187 'auth time difference: ${DateTime .now ().difference (lastAuthTime ).inSeconds }' ,
187188 );
188189
189- return DateTime .now ().difference (lastAuthTime) > authTimeout;
190+ final isTimeout = DateTime .now ().difference (lastAuthTime) > authTimeout;
191+ return isTimeout;
190192 } catch (e) {
191193 debugPrint ('Error checking if authentication is required: $e ' );
192194 return true ; // Err on the side of caution
Original file line number Diff line number Diff line change @@ -225,13 +225,15 @@ class SettingsService {
225225 _prefs.setString (_lastSuccessfulAuthKey, time.toIso8601String ());
226226 }
227227
228+ /// Do not call this directly - call local auth service getAuthTimeoutMinutes() instead.
228229 int ? getAuthTimeout () {
229230 final int ? authTimeout = _prefs.getInt (_authTimeoutKey);
230231 if (authTimeout == null ) return null ;
231232
232233 return authTimeout;
233234 }
234235
236+ /// Do not call this directly - call local auth service setAuthTimeoutMinutes() instead.
235237 void setAuthTimeout (int timeoutDurationInMinutes) {
236238 _prefs.setInt (_authTimeoutKey, timeoutDurationInMinutes);
237239 }
You can’t perform that action at this time.
0 commit comments