File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,10 @@ const { requestLogger, errorLogger } = require('./middlewares/logger');
12
12
const limiter = require ( './utils/limiter' ) ;
13
13
14
14
// IN CASE THERE IS AN ERROR THAT HASN'T BEEN HANDLED
15
- process . on ( 'uncaughtException' , ( err , origin ) => {
16
- // eslint-disable-next-line no-console
17
- console . log ( `ОЙ ${ origin } ${ err . name } c текстом ${ err . message } не была обработана. Сработал глобальный обработчик ошибок.` ) ;
18
- } ) ;
15
+ // process.on('uncaughtException', (err, origin) => {
16
+ // // eslint-disable-next-line no-console
17
+ // console.log(`ОЙ ${origin} ${err.name} c текстом ${err.message} не была обработана. Сработал глобальный обработчик ошибок.`);
18
+ // });
19
19
20
20
const { PORT = 3000 , NODE_ENV , DB_URL = 'mongodb://127.0.0.1:27017/mestodb' } = process . env ;
21
21
Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ const { NODE_ENV, JWT_SECRET } = process.env;
6
6
const auth = ( req , res , next ) => {
7
7
const { authorization } = req . headers ;
8
8
9
- if ( ! authorization . startsWith ( 'Bearer' ) ) {
9
+ if ( ! authorization ) {
10
+ return next ( new UnauthorizedError ( 'Необходима авторизация' ) ) ;
11
+ }
12
+
13
+ if ( authorization && ! authorization . startsWith ( 'Bearer' ) ) {
10
14
return next ( new UnauthorizedError ( 'Необходима авторизация' ) ) ;
11
15
}
12
16
You can’t perform that action at this time.
0 commit comments