fix: 4 audit findings in professionals location flow
- Clear button (✕) now resets _cityMismatch and _detectedCity so banner and CTA unblock - _citiesMatch: replace bidirectional contains with equality + word-prefix check to prevent 'Cali' matching 'Calima' - ProfessionalsProvider: track _currentUserId to reset state on user change (cross-user leak) - ProfessionalsProvider: store _lastSearch so setLocationContext preserves active search term Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
f26b3d3c03
commit
54f9cc272e
@@ -6,12 +6,24 @@ class ProfessionalsProvider extends ChangeNotifier {
|
||||
List<UsuarioProfesional> professionals = [];
|
||||
bool isLoading = true;
|
||||
bool _initialized = false;
|
||||
String? _currentUserId;
|
||||
String? _locationCity;
|
||||
double? _locationLat;
|
||||
double? _locationLng;
|
||||
String? _lastSearch;
|
||||
final _api = ApiService.instance;
|
||||
|
||||
void updateCity(String? city) {
|
||||
void updateCity(String? city, {String? userId}) {
|
||||
// Reset state when a different user logs in (prevents cross-user data leak)
|
||||
if (_currentUserId != userId) {
|
||||
_currentUserId = userId;
|
||||
_initialized = false;
|
||||
_locationCity = null;
|
||||
_locationLat = null;
|
||||
_locationLng = null;
|
||||
_lastSearch = null;
|
||||
professionals = [];
|
||||
}
|
||||
if (!_initialized) {
|
||||
_initialized = true;
|
||||
_locationCity = city;
|
||||
@@ -23,15 +35,16 @@ class ProfessionalsProvider extends ChangeNotifier {
|
||||
if (city != null && city.isNotEmpty) _locationCity = city;
|
||||
_locationLat = lat;
|
||||
_locationLng = lng;
|
||||
getProfessionals();
|
||||
getProfessionals(search: _lastSearch);
|
||||
}
|
||||
|
||||
Future<void> getProfessionals({String? search}) async {
|
||||
if (search != null) _lastSearch = search.trim().isEmpty ? null : search.trim();
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
final params = <String, String>{};
|
||||
if (search != null && search.trim().isNotEmpty) params['search'] = search.trim();
|
||||
if (_lastSearch != null && _lastSearch!.isNotEmpty) params['search'] = _lastSearch!;
|
||||
if (_locationCity != null && _locationCity!.isNotEmpty) params['city'] = _locationCity!.trim();
|
||||
if (_locationLat != null) params['lat'] = _locationLat.toString();
|
||||
if (_locationLng != null) params['lng'] = _locationLng.toString();
|
||||
|
||||
Reference in New Issue
Block a user