This repository has been archived by the owner on Aug 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make all sources compliant with ESLint
- Loading branch information
Logan Glasson
committed
Jul 20, 2018
1 parent
3569269
commit 88e9ce9
Showing
19 changed files
with
52 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
const winston = require('winston') | ||
const winston = require( 'winston' ) | ||
|
||
const Client = require( '../../../../models/UserAppClient') | ||
const Client = require( '../../../../models/UserAppClient' ) | ||
const PermissionCheck = require( '../middleware/PermissionCheck' ) | ||
|
||
module.exports = ( req, res ) => { | ||
if( !req.params.clientId ) { | ||
if ( !req.params.clientId ) { | ||
res.status( 400 ) | ||
return res.send( { success: false, message: 'Malformed request.'} ) | ||
} | ||
Client.findOne( { _id: req.params.clientId } ) | ||
.then( result => PermissionCheck( req.user, 'read', result ) ) | ||
.then( result => { | ||
if( !result ) throw new Error( 'No client found.' ) | ||
if ( !result ) throw new Error( 'No client found.' ) | ||
res.send( { success: true, message: 'Client found.', resource: result } ) | ||
}) | ||
} ) | ||
.catch( err => { | ||
winston.error( err ) | ||
res.status( 400 ) | ||
res.send( { success: false, message: err.toString() } ) | ||
}) | ||
} ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
'use strict' | ||
const winston = require('winston') | ||
const chalk = require('chalk') | ||
const url = require('url') | ||
const User = require('../../../models/User') | ||
const winston = require( 'winston' ) | ||
const chalk = require( 'chalk' ) | ||
const url = require( 'url' ) | ||
const User = require( '../../../models/User' ) | ||
|
||
module.exports = function( info, cb ) { | ||
let location = url.parse(info.req.url, true); | ||
let location = url.parse( info.req.url, true ); | ||
let token = location.query.access_token | ||
|
||
winston.info( chalk.red.underline( 'WS: Access token: ' + token ) ) | ||
if( !token ) | ||
winston.info( chalk.red.underline( 'WS: Access token: ' + token ) ) | ||
if ( !token ) | ||
return cb( false, 401, 'Unauthorized' ) | ||
|
||
User.findOne( { apitoken: token } ) | ||
.then( user => { | ||
if( !user ) throw new Error('WS Auth: User not found. ' + token) | ||
return cb( true, 400, 'Authorized') | ||
}) | ||
if ( !user ) throw new Error( 'WS Auth: User not found. ' + token ) | ||
return cb( true, 400, 'Authorized' ) | ||
} ) | ||
.catch( err => { | ||
winston.error( err ) | ||
return cb( false, 401, 'Unauthorized' ) | ||
}) | ||
} ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters