Browse Source

Merge pull request #290 from provokateurin/feature/delete-app-password

Delete app password when logging out
pull/293/head
Kate 2 years ago committed by GitHub
parent
commit
32c6fb8575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      packages/neon/neon/lib/src/blocs/accounts.dart
  2. 24
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  3. 20
      packages/nextcloud/lib/src/nextcloud.openapi.json
  4. 20
      specs/core.json

9
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) { if (aa != null && aa.id == account.id) {
setActiveAccount(as.isNotEmpty ? as[0] : null); setActiveAccount(as.isNotEmpty ? as[0] : null);
} }
unawaited(() async {
try {
await account.client.core.deleteAppPassword();
} catch (e, s) {
debugPrint(e.toString());
debugPrint(s.toString());
}
}());
} }
@override @override

24
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -433,6 +433,30 @@ class NextcloudCoreClient {
} }
throw NextcloudApiException.fromResponse(response); // coverage:ignore-line throw NextcloudApiException.fromResponse(response); // coverage:ignore-line
} }
Future<dynamic> deleteAppPassword() async {
const path = '/ocs/v2.php/core/apppassword';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'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 { class NextcloudNewsClient {

20
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": { "/index.php/apps/news/api": {
"get": { "get": {
"operationId": "get-supported-api-versions", "operationId": "get-supported-api-versions",

20
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"
}
}
}
}
}
}
} }
} }
} }

Loading…
Cancel
Save