aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-07-05 19:47:47 +0530
committerLibravatar GitHub <noreply@github.com>2021-07-05 19:47:47 +0530
commit96938cd6dd10e77e96d4ab34b6f64a349254d98d (patch)
tree68c9f814980e5cab5614d2c2816330a406749899 /app
parentChange main license holder to Ferdi and remove one existing in docker directory (diff)
parentBump set-getter from 0.1.0 to 0.1.1 (diff)
downloadferdium-server-96938cd6dd10e77e96d4ab34b6f64a349254d98d.tar.gz
ferdium-server-96938cd6dd10e77e96d4ab34b6f64a349254d98d.tar.zst
ferdium-server-96938cd6dd10e77e96d4ab34b6f64a349254d98d.zip
Merge branch 'master' into master
Diffstat (limited to 'app')
-rw-r--r--app/Controllers/Http/DashboardController.js12
-rw-r--r--app/Controllers/Http/ServiceController.js2
-rw-r--r--app/Controllers/Http/StaticController.js9
-rw-r--r--app/Controllers/Http/UserController.js27
-rw-r--r--app/Controllers/Http/WorkspaceController.js3
-rw-r--r--app/Middleware/HandleDoubleSlash.js6
-rw-r--r--app/Models/Token.js2
7 files changed, 42 insertions, 19 deletions
diff --git a/app/Controllers/Http/DashboardController.js b/app/Controllers/Http/DashboardController.js
index 3de4816..a588c75 100644
--- a/app/Controllers/Http/DashboardController.js
+++ b/app/Controllers/Http/DashboardController.js
@@ -63,7 +63,8 @@ class DashboardController {
63 } 63 }
64 try { 64 try {
65 await Persona.forgotPassword(request.input('mail')); 65 await Persona.forgotPassword(request.input('mail'));
66 } catch(e) {} 66 // eslint-disable-next-line no-empty
67 } catch (e) {}
67 68
68 return view.render('others.message', { 69 return view.render('others.message', {
69 heading: 'Reset password', 70 heading: 'Reset password',
@@ -91,11 +92,11 @@ class DashboardController {
91 const payload = { 92 const payload = {
92 password: crypto.createHash('sha256').update(request.input('password')).digest('base64'), 93 password: crypto.createHash('sha256').update(request.input('password')).digest('base64'),
93 password_confirmation: crypto.createHash('sha256').update(request.input('password_confirmation')).digest('base64'), 94 password_confirmation: crypto.createHash('sha256').update(request.input('password_confirmation')).digest('base64'),
94 } 95 };
95 96
96 try { 97 try {
97 await Persona.updatePasswordByToken(request.input('token'), payload); 98 await Persona.updatePasswordByToken(request.input('token'), payload);
98 } catch(e) { 99 } catch (e) {
99 return view.render('others.message', { 100 return view.render('others.message', {
100 heading: 'Cannot reset your password', 101 heading: 'Cannot reset your password',
101 text: 'Please make sure you are using a valid and recent link to reset your password and that your passwords entered match.', 102 text: 'Please make sure you are using a valid and recent link to reset your password and that your passwords entered match.',
@@ -122,6 +123,7 @@ class DashboardController {
122 return view.render('dashboard.account', { 123 return view.render('dashboard.account', {
123 username: auth.user.username, 124 username: auth.user.username,
124 email: auth.user.email, 125 email: auth.user.email,
126 lastname: auth.user.lastname,
125 }); 127 });
126 } 128 }
127 129
@@ -135,6 +137,7 @@ class DashboardController {
135 let validation = await validateAll(request.all(), { 137 let validation = await validateAll(request.all(), {
136 username: 'required', 138 username: 'required',
137 email: 'required', 139 email: 'required',
140 lastname: 'required',
138 }); 141 });
139 if (validation.fails()) { 142 if (validation.fails()) {
140 session.withErrors(validation.messages()).flashExcept(['password']); 143 session.withErrors(validation.messages()).flashExcept(['password']);
@@ -168,6 +171,7 @@ class DashboardController {
168 // Update user account 171 // Update user account
169 const { user } = auth; 172 const { user } = auth;
170 user.username = request.input('username'); 173 user.username = request.input('username');
174 user.lastname = request.input('lastname');
171 user.email = request.input('email'); 175 user.email = request.input('email');
172 if (request.input('password')) { 176 if (request.input('password')) {
173 const hashedPassword = crypto.createHash('sha256').update(request.input('password')).digest('base64'); 177 const hashedPassword = crypto.createHash('sha256').update(request.input('password')).digest('base64');
@@ -192,6 +196,7 @@ class DashboardController {
192 196
193 return view.render('dashboard.data', { 197 return view.render('dashboard.data', {
194 username: general.username, 198 username: general.username,
199 lastname: general.lastname,
195 mail: general.email, 200 mail: general.email,
196 created: general.created_at, 201 created: general.created_at,
197 updated: general.updated_at, 202 updated: general.updated_at,
@@ -211,6 +216,7 @@ class DashboardController {
211 216
212 const exportData = { 217 const exportData = {
213 username: general.username, 218 username: general.username,
219 lastname: general.lastname,
214 mail: general.email, 220 mail: general.email,
215 services, 221 services,
216 workspaces, 222 workspaces,
diff --git a/app/Controllers/Http/ServiceController.js b/app/Controllers/Http/ServiceController.js
index a1d26cb..4aa611c 100644
--- a/app/Controllers/Http/ServiceController.js
+++ b/app/Controllers/Http/ServiceController.js
@@ -140,7 +140,9 @@ class ServiceController {
140 let iconId; 140 let iconId;
141 do { 141 do {
142 iconId = uuid() + uuid(); 142 iconId = uuid() + uuid();
143 // eslint-disable-next-line no-await-in-loop
143 } while (await fs.exists(path.join(Helpers.tmpPath('uploads'), iconId))); 144 } while (await fs.exists(path.join(Helpers.tmpPath('uploads'), iconId)));
145 iconId = `${iconId}.${icon.extname}`;
144 146
145 await icon.move(Helpers.tmpPath('uploads'), { 147 await icon.move(Helpers.tmpPath('uploads'), {
146 name: iconId, 148 name: iconId,
diff --git a/app/Controllers/Http/StaticController.js b/app/Controllers/Http/StaticController.js
index d1a1179..114e369 100644
--- a/app/Controllers/Http/StaticController.js
+++ b/app/Controllers/Http/StaticController.js
@@ -34,7 +34,6 @@ class StaticController {
34 defaultTrialPlan: 'franz-pro-yearly', 34 defaultTrialPlan: 'franz-pro-yearly',
35 subscribeURL: 'https://getferdi.com', 35 subscribeURL: 'https://getferdi.com',
36 planSelectionURL: 'https://getferdi.com', 36 planSelectionURL: 'https://getferdi.com',
37 isMagicBarEnabled: true,
38 hasInlineCheckout: true, 37 hasInlineCheckout: true,
39 isPlanSelectionEnabled: false, 38 isPlanSelectionEnabled: false,
40 isTrialStatusBarEnabled: false, 39 isTrialStatusBarEnabled: false,
@@ -101,9 +100,11 @@ class StaticController {
101 }) { 100 }) {
102 return response.send( 101 return response.send(
103 fs 102 fs
104 .readJsonSync(path.join( 103 .readJsonSync(path.join(
105 Helpers.appRoot(), "officialrecipes", "recipes", "all.json")) 104 Helpers.appRoot(), 'officialrecipes', 'recipes', 'all.json',
106 .filter((recipe) => recipe.featured)); 105 ))
106 .filter((recipe) => recipe.featured),
107 );
107 } 108 }
108 109
109 // Show announcements 110 // Show announcements
diff --git a/app/Controllers/Http/UserController.js b/app/Controllers/Http/UserController.js
index e367d99..0d768a9 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
@@ -174,6 +177,7 @@ class UserController {
174 ...request.all(), 177 ...request.all(),
175 }; 178 };
176 179
180 // eslint-disable-next-line no-param-reassign
177 auth.user.settings = JSON.stringify(newSettings); 181 auth.user.settings = JSON.stringify(newSettings);
178 await auth.user.save(); 182 await auth.user.save();
179 183
@@ -185,13 +189,13 @@ class UserController {
185 email: auth.user.email, 189 email: auth.user.email,
186 emailValidated: true, 190 emailValidated: true,
187 features: {}, 191 features: {},
188 firstname: 'Franz', 192 firstname: auth.user.username,
189 id: '82c1cf9d-ab58-4da2-b55e-aaa41d2142d8', 193 id: '82c1cf9d-ab58-4da2-b55e-aaa41d2142d8',
190 isPremium: true, 194 isPremium: true,
191 isSubscriptionOwner: true, 195 isSubscriptionOwner: true,
192 lastname: 'Franz', 196 lastname: auth.user.lastname,
193 locale: 'en-US', 197 locale: 'en-US',
194 ...newSettings || {}, 198 ...newSettings || {},
195 }, 199 },
196 status: [ 200 status: [
197 'data-updated', 201 'data-updated',
@@ -246,6 +250,7 @@ class UserController {
246 email, 250 email,
247 password: hashedPassword, 251 password: hashedPassword,
248 username: 'Franz', 252 username: 'Franz',
253 lastname: 'Franz',
249 }); 254 });
250 255
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.'); 256 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.');
@@ -258,12 +263,19 @@ class UserController {
258 let token; 263 let token;
259 try { 264 try {
260 const basicToken = btoa(`${email}:${hashedPassword}`); 265 const basicToken = btoa(`${email}:${hashedPassword}`);
266 const loginBody = {
267 isZendeskLogin: false,
268 };
261 269
262 const rawResponse = await fetch(`${base}auth/login`, { 270 const rawResponse = await fetch(`${base}auth/login`, {
263 method: 'POST', 271 method: 'POST',
272 body: JSON.stringify(loginBody),
264 headers: { 273 headers: {
265 Authorization: `Basic ${basicToken}`, 274 Authorization: `Basic ${basicToken}`,
266 'User-Agent': userAgent, 275 'User-Agent': userAgent,
276 'Content-Type': 'application/json',
277 accept: '*/*',
278 'x-franz-source': 'Web',
267 }, 279 },
268 }); 280 });
269 const content = await rawResponse.json(); 281 const content = await rawResponse.json();
@@ -301,6 +313,7 @@ class UserController {
301 email: userInf.email, 313 email: userInf.email,
302 password: hashedPassword, 314 password: hashedPassword,
303 username: userInf.firstname, 315 username: userInf.firstname,
316 lastname: userInf.lastname,
304 }); 317 });
305 } catch (e) { 318 } catch (e) {
306 const errorMessage = `Could not create your user in our system.\nError: ${e}`; 319 const errorMessage = `Could not create your user in our system.\nError: ${e}`;
diff --git a/app/Controllers/Http/WorkspaceController.js b/app/Controllers/Http/WorkspaceController.js
index cbb6873..496912e 100644
--- a/app/Controllers/Http/WorkspaceController.js
+++ b/app/Controllers/Http/WorkspaceController.js
@@ -112,7 +112,8 @@ class WorkspaceController {
112 } 112 }
113 113
114 async delete({ 114 async delete({
115 request, 115 // eslint-disable-next-line no-unused-vars
116 _request,
116 response, 117 response,
117 auth, 118 auth,
118 params, 119 params,
diff --git a/app/Middleware/HandleDoubleSlash.js b/app/Middleware/HandleDoubleSlash.js
index 456b774..c4bc053 100644
--- a/app/Middleware/HandleDoubleSlash.js
+++ b/app/Middleware/HandleDoubleSlash.js
@@ -1,4 +1,3 @@
1'use strict'
2/** @typedef {import('@adonisjs/framework/src/Request')} Request */ 1/** @typedef {import('@adonisjs/framework/src/Request')} Request */
3/** @typedef {import('@adonisjs/framework/src/Response')} Response */ 2/** @typedef {import('@adonisjs/framework/src/Response')} Response */
4/** @typedef {import('@adonisjs/framework/src/View')} View */ 3/** @typedef {import('@adonisjs/framework/src/View')} View */
@@ -9,7 +8,8 @@ class HandleDoubleSlash {
9 * @param {Request} ctx.request 8 * @param {Request} ctx.request
10 * @param {Function} next 9 * @param {Function} next
11 */ 10 */
12 async handle ({ request, response }, next) { 11 // eslint-disable-next-line consistent-return
12 async handle({ request, response }, next) {
13 // Redirect requests that contain duplicate slashes to the right path 13 // Redirect requests that contain duplicate slashes to the right path
14 if (request.url().includes('//')) { 14 if (request.url().includes('//')) {
15 return response.redirect( 15 return response.redirect(
@@ -21,4 +21,4 @@ class HandleDoubleSlash {
21 } 21 }
22} 22}
23 23
24module.exports = HandleDoubleSlash 24module.exports = HandleDoubleSlash;
diff --git a/app/Models/Token.js b/app/Models/Token.js
index 50bcf1d..4a6c286 100644
--- a/app/Models/Token.js
+++ b/app/Models/Token.js
@@ -4,7 +4,7 @@ const Model = use('Model');
4 4
5class Token extends Model { 5class Token extends Model {
6 user() { 6 user() {
7 return this.belongsTo('App/Models/User') 7 return this.belongsTo('App/Models/User');
8 } 8 }
9} 9}
10 10