Рефакторинг
This commit is contained in:
parent
0f18d68914
commit
66c97d5c2d
@ -6,11 +6,11 @@ class Client extends Repository {
|
||||
@override
|
||||
String get apiUrl => "https://api.matule.ru/api";
|
||||
|
||||
AuthModel? _authModel;
|
||||
AuthModel? authModel;
|
||||
|
||||
Options get options => Options(
|
||||
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",
|
||||
data: {"identity": identity, "password": password},
|
||||
);
|
||||
_authModel = AuthModel.fromJSON(response.data);
|
||||
return _authModel!;
|
||||
authModel = AuthModel.fromJSON(response.data);
|
||||
return authModel!;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -9,6 +9,10 @@ class BaseUseCase {
|
||||
BaseUseCase({required this.startLoading, required this.endLoading})
|
||||
: helper = QueryHelper(startLoading: startLoading, endLoading: endLoading);
|
||||
|
||||
AuthModel? getAuth() {
|
||||
return client.authModel;
|
||||
}
|
||||
|
||||
Future<void> login(
|
||||
String identity,
|
||||
String password,
|
||||
|
Loading…
x
Reference in New Issue
Block a user