Skip to content

Commit 097b603

Browse files
committed
Adding jwt expriresIn and algorithm
1 parent d6efee4 commit 097b603

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# react-basic-spa
1+
# react-redux-express-jwt-auth-sqlite
22
BackendとFrontend(React)を使用した何かを作る予定
33

44

backend/app/config/authConfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"secret": "1234567890asdfghjklzxcvbn"
2+
"secret": "1234567890asdfghjklzxcvbn",
3+
"algorithm": "HS256"
34
}

backend/app/controller/common/controllerCommon.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ class controllerCommon {
1111
// ここにjwtロジックを組み込む
1212
// TODO
1313
if (result) {
14-
const token = jwt.sign({ sub: result.id }, authConfig.secret);
14+
const token =
15+
jwt.sign({ sub: result.id },
16+
authConfig.secret,
17+
{ algorithm: authConfig.algorithm, expiresIn: 60 * 60 * 24 });
1518
var authResult = { ...result[0], token };
1619
}
1720
res.status(200); // Found

frontend/package-lock.json

Lines changed: 7 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)