Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
style(eslint): fixed eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
didimitrie committed Jul 30, 2019
1 parent e56d60e commit 36554ec
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017,
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
Expand Down
4 changes: 2 additions & 2 deletions app/api/accounts/UserCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ module.exports = ( req, res ) => {
savedUser = user
return validationToken.save( )
} )
.then( result => {
let verfication = SendEmailVerification( { name: savedUser.name, email: savedUser.email, token: validationToken.token } )
.then( () => {
SendEmailVerification( { name: savedUser.name, email: savedUser.email, token: validationToken.token } )
let token = 'JWT ' + jwt.sign( { _id: myUser._id, name: myUser.name }, sessionSecret, { expiresIn: '24h' } )
return res.send( { success: true, message: 'User saved. Redirect to login.', resource: { apitoken: savedUser.apitoken, token: token, email: savedUser.email }, validationToken: res.token } )
} )
Expand Down
68 changes: 0 additions & 68 deletions app/api/accounts/UserCreateAuth0.js

This file was deleted.

39 changes: 0 additions & 39 deletions app/api/accounts/UserLoginAuth0.js

This file was deleted.

3 changes: 0 additions & 3 deletions app/api/accounts/UserVerify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const winston = require( '../../../config/logger' )
const jwt = require( 'jsonwebtoken' )

const User = require( '../../../models/User' )
const ActionToken = require( '../../../models/ActionToken' )

module.exports = async function ( req, res ) {
Expand Down
4 changes: 2 additions & 2 deletions app/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ module.exports = function ( app, express, urlRoot, plugins ) {
//

// create a new account xxx
r.post( '/accounts/register', process.env.USE_AUTH0 === 'true' ? require( './accounts/UserCreateAuth0' ) : require( './accounts/UserCreate' ) )
r.post( '/accounts/register', require( './accounts/UserCreate' ) )

// login xxx
r.post( '/accounts/login', process.env.USE_AUTH0 === 'true' ? require( './accounts/UserLoginAuth0' ) : require( './accounts/UserLogin' ) )
r.post( '/accounts/login', require( './accounts/UserLogin' ) )

// get profile xxx
r.get( '/accounts', mandatoryAuthorisation, require( './accounts/UserGet' ) )
Expand Down
1 change: 1 addition & 0 deletions app/auth/auth0/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module.exports = {
myUser.role = 'admin'

let namePieces = name.split( /(?<=^\S+)\s/ )

if ( namePieces.length === 2 ) {
myUser.name = namePieces[ 1 ]
myUser.surname = namePieces[ 0 ]
Expand Down
1 change: 1 addition & 0 deletions app/auth/azure-ad/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ module.exports = {
myUser.role = 'admin'

let namePieces = name.split( /(?<=^\S+)\s/ )

if ( namePieces.length === 2 ) {
myUser.name = namePieces[ 1 ]
myUser.surname = namePieces[ 0 ]
Expand Down
9 changes: 2 additions & 7 deletions app/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ const redis = require( 'redis' )
const ExpressSession = require( 'express-session' )
const RedisStore = require( 'connect-redis' )( ExpressSession )


const User = require( '../../models/User' )
const ActionToken = require( '../../models/ActionToken' )
const SendEmailVerification = require( '../../app/email/index' ).SendEmailVerification

let redirectUrls = process.env.REDIRECT_URLS.split( ',' ).filter( r => r !== '' )
redirectUrls.push( process.env.CANONICAL_URL )

module.exports = function ( app, express ) {
module.exports = function ( app ) {

app.engine( '.hbs', exphbs( { extname: '.hbs' } ) )
app.set( 'view engine', '.hbs' )
Expand Down Expand Up @@ -41,7 +36,7 @@ module.exports = function ( app, express ) {
next( )
}

let handleLogin = ( req, res, next ) => {
let handleLogin = ( req, res ) => {
// TODO: also check for potential errors
// TODO: redirect if redirect is present, or display a simple page otherwise
// NOTE: By this point in time, the req.user var should be the speckle user.
Expand Down
15 changes: 7 additions & 8 deletions app/email/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let transporter = nodemailer.createTransport( {
}
} )

transporter.verify( ( err, success ) => {
transporter.verify( ( err ) => {
if ( err )
winston.debug( err )
else {
Expand All @@ -26,7 +26,7 @@ transporter.verify( ( err, success ) => {
exports.SendEmailVerification = ( { name, email, token } ) => {

if ( !initOk ) {
winston.error('Tried sending email before service was initialised.')
winston.error( 'Tried sending email before service was initialised.' )
return
}

Expand Down Expand Up @@ -81,18 +81,17 @@ exports.SendEmailVerification = ( { name, email, token } ) => {

transporter.sendMail( message, ( err ) => {
if ( err ) {
winston.debug( 'OUPS ERRROROR' )
console.log( err )
winston.debug( err )
winston.error( err )
} else {
winston.debug( 'email sent?' )
winston.debug( message )
winston.debug( 'email sent' )
}
} )
}

exports.SendPasswordReset = ( token ) => {
/* eslint-disable */

exports.SendPasswordReset = ( token ) => {
token = 'placeholder'
}

exports.default = {}
13 changes: 6 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const passport = require( 'passport' )
const chalk = require( 'chalk' )
const mongoose = require( 'mongoose' ).set( 'debug', false )
const expressWinston = require( 'express-winston' )
const exphbs = require( 'express-handlebars' )
const redis = require( 'redis' )
const logger = require( './config/logger' )

Expand All @@ -24,23 +23,23 @@ const plugins = require( './plugins' )( )
/// MASTER process /////.
/////////////////////////////////////////////////////////////////////////
if ( cluster.isMaster ) {
console.log( chalk.blue( `
logger.info( chalk.blue( `
█▀▀ █▀▀█ █▀▀ █▀▀▀ █ █ █ █▀▀
▀▀█ █ █ █▀▀ █ █▀▄ █ █▀▀
▀▀▀ █▀▀▀ ▀▀▀ ▀▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀
` ), `
` ) + `
█ https://speckle.works
█ The Open Source Data Platform for AEC.
`,
chalk.red(`
` +
chalk.red( `
█ Server running at: ${process.env.CANONICAL_URL}
`)
` )
)

logger.level = 'debug'
Expand Down Expand Up @@ -147,7 +146,7 @@ chalk.red(`
require( './app/email/index' )

// init default register/login routes
require( './app/auth/index' )( app, express )
require( './app/auth/index' )( app )

/// /////////////////////////////////////////////////////////////////////
/// LAUNCH /////.
Expand Down

0 comments on commit 36554ec

Please sign in to comment.