aboutsummaryrefslogtreecommitdiffstats
path: root/app/Controllers/Http/ServiceController.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controllers/Http/ServiceController.js')
-rw-r--r--app/Controllers/Http/ServiceController.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/Controllers/Http/ServiceController.js b/app/Controllers/Http/ServiceController.js
index d1adea3..0d1bae2 100644
--- a/app/Controllers/Http/ServiceController.js
+++ b/app/Controllers/Http/ServiceController.js
@@ -2,6 +2,10 @@
2 2
3const User = use('App/Models/User'); 3const User = use('App/Models/User');
4const Service = use('App/Models/Service'); 4const Service = use('App/Models/Service');
5const {
6 validateAll
7} = use('Validator');
8
5const uuid = require('uuid/v4'); 9const uuid = require('uuid/v4');
6 10
7class ServiceController { 11class ServiceController {
@@ -17,6 +21,18 @@ class ServiceController {
17 return response.send('Missing or invalid api token') 21 return response.send('Missing or invalid api token')
18 } 22 }
19 23
24 // Validate user input
25 const validation = await validateAll(request.all(), {
26 name: 'required|alpha',
27 recipeId: 'required',
28 });
29 if (validation.fails()) {
30 return response.status(401).send({
31 "message": "Invalid POST arguments",
32 "status": 401
33 })
34 }
35
20 const data = request.all(); 36 const data = request.all();
21 37
22 // Get new, unused uuid 38 // Get new, unused uuid
@@ -65,7 +81,6 @@ class ServiceController {
65 } catch (error) { 81 } catch (error) {
66 return response.send('Missing or invalid api token') 82 return response.send('Missing or invalid api token')
67 } 83 }
68
69 84
70 const services = (await auth.user.services().fetch()).rows; 85 const services = (await auth.user.services().fetch()).rows;
71 // Convert to array with all data Franz wants 86 // Convert to array with all data Franz wants