kopia lustrzana https://gitlab.com/mysocialportal/relatica
32 wiersze
772 B
Dart
32 wiersze
772 B
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:result_monad/result_monad.dart';
|
|
|
|
import '../models/exec_error.dart';
|
|
import '../friendica_client.dart';
|
|
|
|
class AuthService extends ChangeNotifier {
|
|
FriendicaClient? _friendicaClient;
|
|
|
|
Result<FriendicaClient, ExecError> get currentClient {
|
|
if (_friendicaClient == null) {
|
|
return Result.error(ExecError(
|
|
type: ErrorType.authentication,
|
|
message: 'Not logged in',
|
|
));
|
|
}
|
|
|
|
return Result.ok(_friendicaClient!);
|
|
}
|
|
|
|
Result<FriendicaClient, ExecError> updateClient(FriendicaClient newClient) {
|
|
_friendicaClient = newClient;
|
|
notifyListeners();
|
|
return Result.ok(newClient);
|
|
}
|
|
|
|
void clearCredentials() {
|
|
_friendicaClient = null;
|
|
notifyListeners();
|
|
}
|
|
}
|