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

Commit

Permalink
fixed some nasty errors, making sure we're serving api from /v1 too a…
Browse files Browse the repository at this point in the history
…s well, client gen route minor fixes
  • Loading branch information
didimitrie committed Nov 20, 2018
1 parent 11cc95c commit 99aabb0
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
1 change: 0 additions & 1 deletion app/api/accounts/UserLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module.exports = function ( req, res ) {
} )
} )
.catch( err => {
winston.error( err )
res.status( 401 )
res.send( { success: false, message: err } )
} )
Expand Down
2 changes: 1 addition & 1 deletion app/api/clients/ClientPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = ( req, res ) => {

let myClient = new Client( req.body )

if ( !req.user ) { return res.send( { success: true, message: 'Anonymous client created.', resource: { _id: 'temp-' + myClient._id } } ) } else { myClient.owner = req.user._id }
if ( !req.user || req.body.isAnonymous === true ) { return res.send( { success: true, message: 'Anonymous client created.', resource: { _id: 'temp-' + myClient._id } } ) } else { myClient.owner = req.user._id }

myClient.save()
.then( result => {
Expand Down
2 changes: 1 addition & 1 deletion config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function ( passport ) {
passport.use( 'jwt-strict', new JwtStrategy( strictOptions, ( jwtPayload, done ) => {
User.findOne( { _id: jwtPayload._id } )
.then( user => {
if ( !user ) throw new Error( 'No user found' )
if ( !user ) done( err, false ) // not ok
winston.debug( chalk.bgBlue( 'Strict authentication' ), chalk.bgGreen( 'OK' ) )
done( null, user )
} )
Expand Down
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ if ( cluster.isMaster ) {
// handle api versions gracefully
app.use( '/api/v0', ( req, res ) => res.status( 410 ).json( { error: 'The v0 API has been removed' } ) )
require( './app/api/index' )( app, express, '/api' )
require( './app/api/index' )( app, express, '/api/v1' )

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

0 comments on commit 99aabb0

Please sign in to comment.