Skip to content

Commit

Permalink
Mesto Russia (sprint 16): fix after 1 review
Browse files Browse the repository at this point in the history
  • Loading branch information
MalakhN committed May 14, 2023
1 parent 85a65ab commit 4539ccb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ node_modules
# Optional REPL history
.DS_Store
.idea
.vscode
.vscode

# env config files
*.env
.env
3 changes: 2 additions & 1 deletion backend/middlewares/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const jwt = require('jsonwebtoken');

const { NODE_ENV, JWT_SECRET } = process.env;
const { UnauthorizedError } = require('../errors/UnauthorizedError');

Expand All @@ -10,7 +11,7 @@ const auth = (req, res, next) => {
const token = authorization.replace('Bearer ', '');
let payload;
try {
payload = jwt.verify(token, NODE_ENV === 'production' ? JWT_SECRET : 'some-secret-key');
payload = jwt.verify(token, NODE_ENV === 'production' ? JWT_SECRET : 'some-secret-key');
} catch (err) {
throw new UnauthorizedError('Требуется авторизация');
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Routes, Route, Navigate, useNavigate } from "react-router-dom";
import { Api } from "../utils/api";
import Api from "../utils/api";
import { auth } from "../utils/auth";
import { CurrentUserContext } from "../contexts/CurrentUserContext";
import EditProfilePopup from "./EditProfilePopup";
Expand Down

0 comments on commit 4539ccb

Please sign in to comment.