diff options
author | vantezzen <hello@vantezzen.io> | 2019-10-20 17:44:09 +0200 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2019-10-20 17:44:09 +0200 |
commit | f09ebd80b32ee1beac2bfc1de358de14f947bdbc (patch) | |
tree | 4c953014d54bcc896a191a877dd4512f8cec9bf2 /app/Controllers | |
parent | Add page to transfer user accounts (diff) | |
download | ferdium-server-f09ebd80b32ee1beac2bfc1de358de14f947bdbc.tar.gz ferdium-server-f09ebd80b32ee1beac2bfc1de358de14f947bdbc.tar.zst ferdium-server-f09ebd80b32ee1beac2bfc1de358de14f947bdbc.zip |
Implement user settings
Diffstat (limited to 'app/Controllers')
-rw-r--r-- | app/Controllers/Http/UserController.js | 24 |
1 files changed, 24 insertions, 0 deletions
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 { | |||
146 | isSubscriptionOwner: true, | 146 | isSubscriptionOwner: true, |
147 | lastname: 'Franz', | 147 | lastname: 'Franz', |
148 | locale: 'en-US', | 148 | locale: 'en-US', |
149 | ...auth.user.settings || {}, | ||
150 | }); | ||
151 | } | ||
152 | |||
153 | async updateMe({ | ||
154 | request, | ||
155 | response, | ||
156 | auth | ||
157 | }) { | ||
158 | let settings = auth.user.settings || {}; | ||
159 | if (typeof settings === 'string') { | ||
160 | settings = JSON.parse(settings); | ||
161 | } | ||
162 | |||
163 | let newSettings = { | ||
164 | ...settings, | ||
165 | ...request.all(), | ||
166 | } | ||
167 | |||
168 | auth.user.settings = JSON.stringify(newSettings); | ||
169 | await auth.user.save(); | ||
170 | |||
171 | return response.send({ | ||
172 | status: 'success' | ||
149 | }); | 173 | }); |
150 | } | 174 | } |
151 | 175 | ||