diff options
author | 2021-02-07 10:58:00 +0100 | |
---|---|---|
committer | 2021-02-07 10:58:00 +0100 | |
commit | 9b8c614bbb3341fa26ecaa5fdec1a23629c92eb1 (patch) | |
tree | 37829eb685cf8f4e12a6fdd3a4bdbefaccc94f50 /app/Controllers/Http | |
parent | Merge pull request #47 from cromefire/db-path (diff) | |
parent | Fix regarding CR comments - username should be added to user and not to works... (diff) | |
download | ferdium-server-9b8c614bbb3341fa26ecaa5fdec1a23629c92eb1.tar.gz ferdium-server-9b8c614bbb3341fa26ecaa5fdec1a23629c92eb1.tar.zst ferdium-server-9b8c614bbb3341fa26ecaa5fdec1a23629c92eb1.zip |
Merge pull request #50 from k0staa/bug/account_settings_display_franz_fix
Diffstat (limited to 'app/Controllers/Http')
-rw-r--r-- | app/Controllers/Http/DashboardController.js | 5 | ||||
-rw-r--r-- | app/Controllers/Http/UserController.js | 19 |
2 files changed, 17 insertions, 7 deletions
diff --git a/app/Controllers/Http/DashboardController.js b/app/Controllers/Http/DashboardController.js index 3de4816..2f06961 100644 --- a/app/Controllers/Http/DashboardController.js +++ b/app/Controllers/Http/DashboardController.js | |||
@@ -122,6 +122,7 @@ class DashboardController { | |||
122 | return view.render('dashboard.account', { | 122 | return view.render('dashboard.account', { |
123 | username: auth.user.username, | 123 | username: auth.user.username, |
124 | email: auth.user.email, | 124 | email: auth.user.email, |
125 | lastname: auth.user.lastname | ||
125 | }); | 126 | }); |
126 | } | 127 | } |
127 | 128 | ||
@@ -135,6 +136,7 @@ class DashboardController { | |||
135 | let validation = await validateAll(request.all(), { | 136 | let validation = await validateAll(request.all(), { |
136 | username: 'required', | 137 | username: 'required', |
137 | email: 'required', | 138 | email: 'required', |
139 | lastname: 'required' | ||
138 | }); | 140 | }); |
139 | if (validation.fails()) { | 141 | if (validation.fails()) { |
140 | session.withErrors(validation.messages()).flashExcept(['password']); | 142 | session.withErrors(validation.messages()).flashExcept(['password']); |
@@ -168,6 +170,7 @@ class DashboardController { | |||
168 | // Update user account | 170 | // Update user account |
169 | const { user } = auth; | 171 | const { user } = auth; |
170 | user.username = request.input('username'); | 172 | user.username = request.input('username'); |
173 | user.lastname = request.input('lastname'); | ||
171 | user.email = request.input('email'); | 174 | user.email = request.input('email'); |
172 | if (request.input('password')) { | 175 | if (request.input('password')) { |
173 | const hashedPassword = crypto.createHash('sha256').update(request.input('password')).digest('base64'); | 176 | const hashedPassword = crypto.createHash('sha256').update(request.input('password')).digest('base64'); |
@@ -192,6 +195,7 @@ class DashboardController { | |||
192 | 195 | ||
193 | return view.render('dashboard.data', { | 196 | return view.render('dashboard.data', { |
194 | username: general.username, | 197 | username: general.username, |
198 | lastname: general.lastname, | ||
195 | mail: general.email, | 199 | mail: general.email, |
196 | created: general.created_at, | 200 | created: general.created_at, |
197 | updated: general.updated_at, | 201 | updated: general.updated_at, |
@@ -211,6 +215,7 @@ class DashboardController { | |||
211 | 215 | ||
212 | const exportData = { | 216 | const exportData = { |
213 | username: general.username, | 217 | username: general.username, |
218 | lastname: general.lastname, | ||
214 | mail: general.email, | 219 | mail: general.email, |
215 | services, | 220 | services, |
216 | workspaces, | 221 | workspaces, |
diff --git a/app/Controllers/Http/UserController.js b/app/Controllers/Http/UserController.js index e367d99..dc92b21 100644 --- a/app/Controllers/Http/UserController.js +++ b/app/Controllers/Http/UserController.js | |||
@@ -48,9 +48,11 @@ class UserController { | |||
48 | // Validate user input | 48 | // Validate user input |
49 | const validation = await validateAll(request.all(), { | 49 | const validation = await validateAll(request.all(), { |
50 | firstname: 'required', | 50 | firstname: 'required', |
51 | lastname: 'required', | ||
51 | email: 'required|email|unique:users,email', | 52 | email: 'required|email|unique:users,email', |
52 | password: 'required', | 53 | password: 'required', |
53 | }); | 54 | }); |
55 | |||
54 | if (validation.fails()) { | 56 | if (validation.fails()) { |
55 | return response.status(401).send({ | 57 | return response.status(401).send({ |
56 | message: 'Invalid POST arguments', | 58 | message: 'Invalid POST arguments', |
@@ -59,7 +61,7 @@ class UserController { | |||
59 | }); | 61 | }); |
60 | } | 62 | } |
61 | 63 | ||
62 | const data = request.only(['firstname', 'email', 'password']); | 64 | const data = request.only(['firstname', 'lastname', 'email', 'password']); |
63 | 65 | ||
64 | // Create user in DB | 66 | // Create user in DB |
65 | let user; | 67 | let user; |
@@ -68,6 +70,7 @@ class UserController { | |||
68 | email: data.email, | 70 | email: data.email, |
69 | password: data.password, | 71 | password: data.password, |
70 | username: data.firstname, | 72 | username: data.firstname, |
73 | lastname: data.lastname, | ||
71 | }); | 74 | }); |
72 | } catch (e) { | 75 | } catch (e) { |
73 | return response.status(401).send({ | 76 | return response.status(401).send({ |
@@ -149,13 +152,13 @@ class UserController { | |||
149 | email: auth.user.email, | 152 | email: auth.user.email, |
150 | emailValidated: true, | 153 | emailValidated: true, |
151 | features: {}, | 154 | features: {}, |
152 | firstname: 'Franz', | 155 | firstname: auth.user.username, |
153 | id: '82c1cf9d-ab58-4da2-b55e-aaa41d2142d8', | 156 | id: '82c1cf9d-ab58-4da2-b55e-aaa41d2142d8', |
154 | isPremium: true, | 157 | isPremium: true, |
155 | isSubscriptionOwner: true, | 158 | isSubscriptionOwner: true, |
156 | lastname: 'Franz', | 159 | lastname: auth.user.lastname, |
157 | locale: 'en-US', | 160 | locale: 'en-US', |
158 | ...settings || {}, | 161 | ...settings || {}, |
159 | }); | 162 | }); |
160 | } | 163 | } |
161 | 164 | ||
@@ -185,13 +188,13 @@ class UserController { | |||
185 | email: auth.user.email, | 188 | email: auth.user.email, |
186 | emailValidated: true, | 189 | emailValidated: true, |
187 | features: {}, | 190 | features: {}, |
188 | firstname: 'Franz', | 191 | firstname: auth.user.username, |
189 | id: '82c1cf9d-ab58-4da2-b55e-aaa41d2142d8', | 192 | id: '82c1cf9d-ab58-4da2-b55e-aaa41d2142d8', |
190 | isPremium: true, | 193 | isPremium: true, |
191 | isSubscriptionOwner: true, | 194 | isSubscriptionOwner: true, |
192 | lastname: 'Franz', | 195 | lastname: auth.user.lastname, |
193 | locale: 'en-US', | 196 | locale: 'en-US', |
194 | ...newSettings || {}, | 197 | ...newSettings || {}, |
195 | }, | 198 | }, |
196 | status: [ | 199 | status: [ |
197 | 'data-updated', | 200 | 'data-updated', |
@@ -246,6 +249,7 @@ class UserController { | |||
246 | email, | 249 | email, |
247 | password: hashedPassword, | 250 | password: hashedPassword, |
248 | username: 'Franz', | 251 | username: 'Franz', |
252 | lastname: 'Franz' | ||
249 | }); | 253 | }); |
250 | 254 | ||
251 | return response.send('Your account has been created but due to this server\'s configuration, we could not import your Franz account data.\n\nIf you are the server owner, please set CONNECT_WITH_FRANZ to true to enable account imports.'); | 255 | return response.send('Your account has been created but due to this server\'s configuration, we could not import your Franz account data.\n\nIf you are the server owner, please set CONNECT_WITH_FRANZ to true to enable account imports.'); |
@@ -301,6 +305,7 @@ class UserController { | |||
301 | email: userInf.email, | 305 | email: userInf.email, |
302 | password: hashedPassword, | 306 | password: hashedPassword, |
303 | username: userInf.firstname, | 307 | username: userInf.firstname, |
308 | lastname: userInf.lastname | ||
304 | }); | 309 | }); |
305 | } catch (e) { | 310 | } catch (e) { |
306 | const errorMessage = `Could not create your user in our system.\nError: ${e}`; | 311 | const errorMessage = `Could not create your user in our system.\nError: ${e}`; |