Skip to content
Permalink
Browse files

Add eslint

  • Loading branch information
vantezzen committed Sep 5, 2019
1 parent 9d99383 commit 29b8334b060dc0c05a509d523ead4b3a30229fef
Showing with 2,104 additions and 840 deletions.
  1. +22 βˆ’0 .eslintrc.js
  2. +31 βˆ’30 app/Controllers/Http/DashboardController.js
  3. +77 βˆ’82 app/Controllers/Http/RecipeController.js
  4. +97 βˆ’103 app/Controllers/Http/ServiceController.js
  5. +173 βˆ’174 app/Controllers/Http/StaticController.js
  6. +101 βˆ’112 app/Controllers/Http/UserController.js
  7. +51 βˆ’53 app/Controllers/Http/WorkspaceController.js
  8. +8 βˆ’8 app/Exceptions/Handler.js
  9. +7 βˆ’8 app/Middleware/ConvertEmptyStringsToNull.js
  10. +2 βˆ’3 app/Models/Recipe.js
  11. +5 βˆ’6 app/Models/Service.js
  12. +2 βˆ’3 app/Models/Token.js
  13. +4 βˆ’5 app/Models/Traits/NoTimestamp.js
  14. +14 βˆ’14 app/Models/User.js
  15. +5 βˆ’6 app/Models/Workspace.js
  16. +11 βˆ’12 config/app.js
  17. +8 βˆ’9 config/auth.js
  18. +10 βˆ’11 config/bodyParser.js
  19. +2 βˆ’3 config/cors.js
  20. +10 βˆ’11 config/database.js
  21. +7 βˆ’10 config/drive.js
  22. +5 βˆ’6 config/hash.js
  23. +6 βˆ’7 config/session.js
  24. +6 βˆ’7 config/shield.js
  25. +0 βˆ’1 database/factory.js
  26. +11 βˆ’12 database/migrations/1503250034279_user.js
  27. +12 βˆ’13 database/migrations/1503250034280_token.js
  28. +13 βˆ’14 database/migrations/1566385379883_service_schema.js
  29. +11 βˆ’12 database/migrations/1566554231482_recipe_schema.js
  30. +14 βˆ’15 database/migrations/1566554359294_workspace_schema.js
  31. +1,291 βˆ’4 package-lock.json
  32. +11 βˆ’2 package.json
  33. +5 βˆ’4 public/js/new.js
  34. +4 βˆ’4 server.js
  35. +8 βˆ’7 start/app.js
  36. +6 βˆ’7 start/kernel.js
  37. +54 βˆ’62 start/routes.js
@@ -0,0 +1,22 @@
module.exports = {
env: {
commonjs: true,
es6: true,
node: true,
},
extends: [
'airbnb-base',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
use: 'readonly'
},
parserOptions: {
ecmaVersion: 2018,
},
rules: {
"class-methods-use-this": 'off',
"no-restricted-syntax": 'off',
},
};
@@ -1,7 +1,6 @@
'use strict'

const {
validateAll
validateAll,
} = use('Validator');

const crypto = require('crypto');
@@ -11,7 +10,7 @@ class DashboardController {
request,
response,
auth,
session
session,
}) {
const validation = await validateAll(request.all(), {
mail: 'required|email',
@@ -20,43 +19,44 @@ class DashboardController {
if (validation.fails()) {
session.withErrors({
type: 'danger',
message: 'Invalid mail or password'
message: 'Invalid mail or password',
}).flashExcept(['password']);
return response.redirect('back');
}

let {
const {
mail,
password
} = request.all()
password,
} = request.all();

const hashedPassword = crypto.createHash('sha256').update(password).digest('base64');

try {
await auth.authenticator('session').attempt(mail, hashedPassword)
await auth.authenticator('session').attempt(mail, hashedPassword);
} catch (error) {
session.flash({
type: 'danger',
message: 'Invalid mail or password'
})
message: 'Invalid mail or password',
});
return response.redirect('back');
}
return response.redirect('/user/account');
}

async account({
auth,
view
view,
response,
}) {
try {
await auth.check()
await auth.check();
} catch (error) {
return response.redirect('/user/login');
}

return view.render('dashboard.account', {
username: auth.user.username,
email: auth.user.email
email: auth.user.email,
});
}

@@ -65,11 +65,11 @@ class DashboardController {
request,
session,
view,
response
response,
}) {
let validation = await validateAll(request.all(), {
username: 'required',
email: 'required'
email: 'required',
});
if (validation.fails()) {
session.withErrors(validation.messages()).flashExcept(['password']);
@@ -80,19 +80,19 @@ class DashboardController {
if (request.input('username') !== auth.user.username) {
validation = await validateAll(request.all(), {
username: 'required|unique:users,username',
email: 'required'
email: 'required',
});
if (validation.fails()) {
session.withErrors(validation.messages()).flashExcept(['password']);
return response.redirect('back');
}
}
}

// Check new email
if (request.input('email') !== auth.user.email) {
validation = await validateAll(request.all(), {
username: 'required',
email: 'required|email|unique:users,email'
email: 'required|email|unique:users,email',
});
if (validation.fails()) {
session.withErrors(validation.messages()).flashExcept(['password']);
@@ -101,24 +101,25 @@ class DashboardController {
}

// Update user account
auth.user.username = request.input('username');
auth.user.email = request.input('email');
if (!!request.input('password')) {
const { user } = auth;
user.username = request.input('username');
user.email = request.input('email');
if (request.input('password')) {
const hashedPassword = crypto.createHash('sha256').update(request.input('password')).digest('base64');
auth.user.password = hashedPassword;
user.password = hashedPassword;
}
auth.user.save();
user.save();

return view.render('dashboard.account', {
username: auth.user.username,
email: auth.user.email,
success: true
username: user.username,
email: user.email,
success: true,
});
}

async data({
auth,
view
view,
}) {
const general = auth.user;
const services = (await auth.user.services().fetch()).toJSON();
@@ -136,20 +137,20 @@ class DashboardController {

logout({
auth,
response
response,
}) {
auth.authenticator('session').logout();
return response.redirect('/user/login');
}

delete({
auth,
response
response,
}) {
auth.user.delete();
auth.authenticator('session').logout();
return response.redirect('/user/login');
}
}

module.exports = DashboardController
module.exports = DashboardController;

0 comments on commit 29b8334

Please sign in to comment.
You can’t perform that action at this time.