kopia lustrzana https://gitlab.com/mysocialportal/relatica
Add AuthService initial cut
rodzic
4956208928
commit
bde1aab519
|
@ -0,0 +1,31 @@
|
|||
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();
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue