diff --git a/bin/server.dart b/bin/server.dart index 79cff1e..9d68a6e 100755 --- a/bin/server.dart +++ b/bin/server.dart @@ -8,16 +8,16 @@ import 'package:shelf_router/shelf_router.dart'; final _router = Router() // GET ..get('/', API.rootHandler) + // POST (EN VRAI C'EST DES GET AVEC UN BODY) + ..post('/user/password-file', API.downloadPasswordDb) ..post('/auth', API.authenticator) - ..get('/user/down-password-file', API.downloadPasswordDb) - // POST - ..post('/user/create-account', API.createAccount) + ..post('/user/account', API.createAccount) // vrai post // PUT - ..put('/user/change-master-password', API.changeMasterPassword) - ..put('/user/up-password-file', API.uploadPasswordDb) + ..put('/user/master-password', API.changeMasterPassword) + ..put('/user/password-file', API.uploadPasswordDb) ..put('/user/change-mail', API.changeMail) // DELETE - ..delete('/user/delete-account', API.deleteAccount); + ..delete('/user/account', API.deleteAccount); /* Response _fileHandler(Request req) { diff --git a/lib/api/api.dart b/lib/api/api.dart index 9ed9a42..21a0416 100644 --- a/lib/api/api.dart +++ b/lib/api/api.dart @@ -76,4 +76,22 @@ class API { static Response deleteAccount(Request req) { return Response.ok(""); } + + /*---------------| + |-------MISC-----| + |---------------*/ + + // Check if required fields are in req body + static Future checkRequiredFields( + List fields, Request req) async { + // json object read -> check dic keys + final body = await req.readAsString(); + bool check = false; + for (String s in fields) { + if (req.params['$s'] == "") { + return false; + } + } + return true; + } } diff --git a/pubspec.lock b/pubspec.lock index 6f00e59..fc673b5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "49.0.0" + version: "50.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "5.1.0" + version: "5.2.0" args: dependency: "direct main" description: @@ -28,21 +28,21 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.9.0" + version: "2.10.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.16.0" + version: "1.17.0" convert: dependency: transitive description: @@ -77,14 +77,14 @@ packages: name: frontend_server_client url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.2.0" glob: dependency: transitive description: name: glob url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" http: dependency: "direct dev" description: @@ -112,7 +112,7 @@ packages: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "4.0.1" + version: "4.0.2" io: dependency: transitive description: @@ -126,14 +126,14 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.4" + version: "0.6.5" lints: dependency: "direct dev" description: name: lints url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" logging: dependency: transitive description: @@ -147,7 +147,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.12" + version: "0.12.13" meta: dependency: transitive description: @@ -196,7 +196,7 @@ packages: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.3" shelf: dependency: "direct main" description: @@ -231,21 +231,21 @@ packages: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" source_map_stack_trace: dependency: transitive description: name: source_map_stack_trace url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" source_maps: dependency: transitive description: name: source_maps url: "https://pub.dartlang.org" source: hosted - version: "0.10.10" + version: "0.10.11" source_span: dependency: transitive description: @@ -259,7 +259,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: @@ -273,7 +273,7 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: @@ -287,21 +287,21 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.21.6" + version: "1.22.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.14" + version: "0.4.16" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.4.18" + version: "0.4.20" typed_data: dependency: transitive description: @@ -322,7 +322,7 @@ packages: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" web_socket_channel: dependency: transitive description: