Skip to content

Commit 020fdae

Browse files
authored
Merge pull request #16 from ioedeveloper/dev
JWT Authorization
2 parents 58e7e8a + a7ad3e8 commit 020fdae

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/api/user.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { UserService } from '../service/userService';
44
import * as dotenv from 'dotenv';
55
import * as path from 'path';
66
import * as jwt from 'jsonwebtoken';
7-
import * as appConfig from '../config';
7+
import appConfig from '../config';
88
import { isAuthorized } from '../middleware/authorization';
99
dotenv.config();
1010

@@ -27,7 +27,7 @@ router.post('/signup', async function(req: Request, res: Response) {
2727
jwtAccessToken: `${
2828
jwt.sign({
2929
id: newUser._id,
30-
}, appConfig.default.jwtSecretKey, { expiresIn: 3600000 })
30+
}, appConfig.jwtSecretKey, { expiresIn: 3600000 })
3131
}`,
3232
jwtRefreshToken: newUser.jwtRefreshToken,
3333
},
@@ -68,7 +68,7 @@ router.post('/signin', async function(req: Request, res: Response) {
6868
jwtAccessToken: `${
6969
jwt.sign({
7070
id: user._id,
71-
}, appConfig.default.jwtSecretKey, { expiresIn: 3600000 })
71+
}, appConfig.jwtSecretKey, { expiresIn: 3600000 })
7272
}`,
7373
jwtRefreshToken: user.jwtRefreshToken,
7474
},

src/config/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import * as dotenv from 'dotenv';
22
dotenv.config();
33

44
export default {
5-
host: process.env.NODE_ENV === 'development' ? 'https://a4f546eb.ngrok.io' : 'https://gitshadow.herokuapp.com',
6-
jwtSecretKey: process.env.JWT_SECRET ? process.env.JWT_SECRET : 'git-shadow',
5+
host: process.env.NODE_ENV === 'development' ? 'https://55293a2b.ngrok.io' : 'https://gitshadow.herokuapp.com',
6+
jwtSecretKey: process.env.JWT_SECRET_KEY ? process.env.JWT_SECRET_KEY : 'git-shadow',
77
};

src/service/userService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { UserDataService } from './userDataService';
33
import * as bcrypt from 'bcrypt';
44
import { v1 } from 'uuid';
55
import axios from 'axios';
6+
import appConfig from '../config';
67
import * as dotenv from 'dotenv';
78
dotenv.config();
89

0 commit comments

Comments
 (0)