Рефакторинг

This commit is contained in:
PROF25-FINAL 2025-05-27 16:25:45 +03:00
parent 0f18d68914
commit 66c97d5c2d
2 changed files with 8 additions and 4 deletions

View File

@ -6,11 +6,11 @@ class Client extends Repository {
@override @override
String get apiUrl => "https://api.matule.ru/api"; String get apiUrl => "https://api.matule.ru/api";
AuthModel? _authModel; AuthModel? authModel;
Options get options => Options( Options get options => Options(
headers: { headers: {
if (_authModel != null) "Authorization": "Bearer ${_authModel!.token}", if (authModel != null) "Authorization": "Bearer ${authModel!.token}",
}, },
); );
@ -20,8 +20,8 @@ class Client extends Repository {
"$apiUrl/collections/users/auth-with-password", "$apiUrl/collections/users/auth-with-password",
data: {"identity": identity, "password": password}, data: {"identity": identity, "password": password},
); );
_authModel = AuthModel.fromJSON(response.data); authModel = AuthModel.fromJSON(response.data);
return _authModel!; return authModel!;
} }
@override @override

View File

@ -9,6 +9,10 @@ class BaseUseCase {
BaseUseCase({required this.startLoading, required this.endLoading}) BaseUseCase({required this.startLoading, required this.endLoading})
: helper = QueryHelper(startLoading: startLoading, endLoading: endLoading); : helper = QueryHelper(startLoading: startLoading, endLoading: endLoading);
AuthModel? getAuth() {
return client.authModel;
}
Future<void> login( Future<void> login(
String identity, String identity,
String password, String password,