From f09ebd80b32ee1beac2bfc1de358de14f947bdbc Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sun, 20 Oct 2019 17:44:09 +0200 Subject: Implement user settings --- app/Controllers/Http/UserController.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'app/Controllers') diff --git a/app/Controllers/Http/UserController.js b/app/Controllers/Http/UserController.js index 1e67092..3f6103a 100644 --- a/app/Controllers/Http/UserController.js +++ b/app/Controllers/Http/UserController.js @@ -146,6 +146,30 @@ class UserController { isSubscriptionOwner: true, lastname: 'Franz', locale: 'en-US', + ...auth.user.settings || {}, + }); + } + + async updateMe({ + request, + response, + auth + }) { + let settings = auth.user.settings || {}; + if (typeof settings === 'string') { + settings = JSON.parse(settings); + } + + let newSettings = { + ...settings, + ...request.all(), + } + + auth.user.settings = JSON.stringify(newSettings); + await auth.user.save(); + + return response.send({ + status: 'success' }); } -- cgit v1.2.3-54-g00ecf