Рефакторинг
This commit is contained in:
parent
0f18d68914
commit
66c97d5c2d
@ -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
|
||||||
|
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user