Skip to content

Commit

Permalink
Merge pull request #2 from tar-aldev/dev
Browse files Browse the repository at this point in the history
updated gitignore
  • Loading branch information
tar-aldev authored Dec 4, 2019
2 parents 865f207 + 7e9efee commit 56176bf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PORT = 8000
MONGODB_URI="mongodb://localhost/blog"
ACCESS_TOKEN_SECRET=
REFRESH_TOKEN_SECRET=
ACCESS_TOKEN_EXP=300
# 15 days
REFRESH_TOKEN_EXP=1296000
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
credentials.json
.env
.idea/
8 changes: 4 additions & 4 deletions middleware/withAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ module.exports = (error = true) => (req, res, next) => {
const { authorization } = req.headers;
try {
const token = authorization.split(" ")[1];
req.jwtPayload = jwt.verify(token, "secret");
req.jwtPayload = jwt.verify(token, process.env.ACCESS_TOKEN_SECRET);
next();
} catch (e) {
console.log("error token decode", e);
if (error) {
return res.status(401).json({
message: e.message || "Not authenticated!",
});
return res
.status(401)
.json({ message: e.message || "Not authenticated!" });
}
req.jwtPayload = {};
next();
Expand Down
5 changes: 2 additions & 3 deletions modules/auth/auth.controller.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const User = require("../users/users.model");
const Token = require("./tokens.model");
const {
signJWT,
getUrlGoogle,
getGoogleAccountByCode,
generateNickname,
} = require("../../utils/index");

/*
/*
acces token - short term of expiration short validity period
refresh token - used to generate access token.
Used only once - after this old refresh token is deleted and new one is generated
Expand Down Expand Up @@ -78,7 +77,7 @@ module.exports = {
}
/* let user = await User.findOne({
gmailId: userGmailId,
}); */
});
/* if (!user) {
const newUser = new User({
gmailId: userGmailId,
Expand Down
Binary file added public/images/avatar-157537079181951.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 56176bf

Please sign in to comment.