Skip to content

Commit 746bbfd

Browse files
author
lucifer
committed
fix: ctx.session
1 parent cb552ce commit 746bbfd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

middleware/passport.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const db = [
1111
];
1212

1313
module.exports = async function checkAuth(ctx, next) {
14+
if (!ctx.session) {
15+
ctx.session = {};
16+
}
1417
const token = ctx.cookies.get("token");
1518

1619
if (token) {
@@ -63,9 +66,7 @@ module.exports = async function checkAuth(ctx, next) {
6366
expires: new Date(24 * 60 * 60 * 1000 + Date.now()),
6467
}
6568
);
66-
if (!ctx.session) {
67-
ctx.session = {};
68-
}
69+
6970
ctx.session.user = {
7071
...user,
7172
pay: true,

0 commit comments

Comments
 (0)