diff --git a/packages/neon/neon/lib/src/blocs/accounts.dart b/packages/neon/neon/lib/src/blocs/accounts.dart index fc12a79d..63fcf732 100644 --- a/packages/neon/neon/lib/src/blocs/accounts.dart +++ b/packages/neon/neon/lib/src/blocs/accounts.dart @@ -97,6 +97,15 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState if (aa != null && aa.id == account.id) { setActiveAccount(as.isNotEmpty ? as[0] : null); } + + unawaited(() async { + try { + await account.client.core.deleteAppPassword(); + } catch (e, s) { + debugPrint(e.toString()); + debugPrint(s.toString()); + } + }()); } @override diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.dart b/packages/nextcloud/lib/src/nextcloud.openapi.dart index ef49897d..db9e6912 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.dart @@ -433,6 +433,30 @@ class NextcloudCoreClient { } throw NextcloudApiException.fromResponse(response); // coverage:ignore-line } + + Future deleteAppPassword() async { + const path = '/ocs/v2.php/core/apppassword'; + final queryParameters = {}; + final headers = { + 'Accept': 'application/json', + }; + Uint8List? body; + if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) { + headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers); + } else { + throw Exception('Missing authentication for basic_auth'); + } + final response = await rootClient.doRequest( + 'delete', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), + headers, + body, + ); + if (response.statusCode == 200) { + return; + } + throw NextcloudApiException.fromResponse(response); // coverage:ignore-line + } } class NextcloudNewsClient { diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.json b/packages/nextcloud/lib/src/nextcloud.openapi.json index f41dcb88..3b7e4a4f 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.json +++ b/packages/nextcloud/lib/src/nextcloud.openapi.json @@ -2343,6 +2343,26 @@ } } }, + "/ocs/v2.php/core/apppassword": { + "delete": { + "tags": [ + "core" + ], + "operationId": "delete-app-password", + "responses": { + "200": { + "description": "App password deleted successfully", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, "/index.php/apps/news/api": { "get": { "operationId": "get-supported-api-versions", diff --git a/specs/core.json b/specs/core.json index a88c14d2..6ed8a375 100644 --- a/specs/core.json +++ b/specs/core.json @@ -1318,6 +1318,26 @@ } } } + }, + "/ocs/v2.php/core/apppassword": { + "delete": { + "tags": [ + "core" + ], + "operationId": "delete-app-password", + "responses": { + "200": { + "description": "App password deleted successfully", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } } } }