Support purging clients
This commit is contained in:
parent
4332740421
commit
b00a44c11a
|
|
@ -680,7 +680,7 @@ abstract class ClientEntity extends Object
|
|||
|
||||
actions..addAll(super.getActions(userCompany: userCompany));
|
||||
|
||||
if (false && userCompany.isAdmin && !multiselect) {
|
||||
if (userCompany.isAdmin && !multiselect) {
|
||||
actions.add(EntityAction.purge);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,10 +67,16 @@ class ClientRepository {
|
|||
return clientResponse.data.toList();
|
||||
}
|
||||
|
||||
Future<bool> purge(Credentials credentials, String id) async {
|
||||
final url = credentials.url + '/clients/$id/purge';
|
||||
Future<bool> purge({
|
||||
@required Credentials credentials,
|
||||
@required String clientId,
|
||||
@required String password,
|
||||
@required String idToken,
|
||||
}) async {
|
||||
final url = credentials.url + '/clients/$clientId/purge';
|
||||
|
||||
await webClient.post(url, credentials.token);
|
||||
await webClient.post(url, credentials.token,
|
||||
password: password, idToken: idToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,10 +224,17 @@ class DeleteClientsFailure implements StopSaving {
|
|||
}
|
||||
|
||||
class PurgeClientRequest implements StartSaving {
|
||||
PurgeClientRequest(this.completer, this.clientId);
|
||||
PurgeClientRequest({
|
||||
@required this.completer,
|
||||
@required this.clientId,
|
||||
@required this.password,
|
||||
@required this.idToken,
|
||||
});
|
||||
|
||||
final Completer completer;
|
||||
final String clientId;
|
||||
final String password;
|
||||
final String idToken;
|
||||
}
|
||||
|
||||
class PurgeClientSuccess implements StopSaving, PersistData {}
|
||||
|
|
@ -442,9 +449,11 @@ void handleClientAction(
|
|||
callback: (password, idToken) {
|
||||
store.dispatch(
|
||||
PurgeClientRequest(
|
||||
snackBarCompleter<Null>(
|
||||
completer: snackBarCompleter<Null>(
|
||||
context, localization.purgedClient),
|
||||
client.id),
|
||||
clientId: client.id,
|
||||
password: password,
|
||||
idToken: idToken),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -154,7 +154,14 @@ Middleware<AppState> _deleteClient(ClientRepository repository) {
|
|||
Middleware<AppState> _purgeClient(ClientRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as PurgeClientRequest;
|
||||
repository.purge(store.state.credentials, action.clientId).then((_) {
|
||||
repository
|
||||
.purge(
|
||||
credentials: store.state.credentials,
|
||||
clientId: action.clientId,
|
||||
password: action.password,
|
||||
idToken: action.idToken,
|
||||
)
|
||||
.then((_) {
|
||||
store.dispatch(PurgeClientSuccess());
|
||||
store.dispatch(RefreshData(
|
||||
clearData: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue