File tree Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -51,22 +51,26 @@ module.exports = async function checkAuth(ctx, next) {
51
51
Authorization : `token ${ access_token } ` ,
52
52
} ,
53
53
} ) . then ( ( res ) => res . json ( ) ) ;
54
- ctx . cookies . set (
55
- "token" ,
56
- encrypt (
57
- Buffer . from (
58
- JSON . stringify ( {
59
- ...user ,
60
- pay : true ,
61
- } ) ,
62
- "utf8"
63
- )
64
- ) ,
65
- {
66
- httpOnly : false ,
67
- expires : new Date ( 24 * 60 * 60 * 1000 + Date . now ( ) ) ,
68
- }
69
- ) ;
54
+
55
+ // user.login 存在表示登录成功
56
+ if ( user . login ) {
57
+ ctx . cookies . set (
58
+ "token" ,
59
+ encrypt (
60
+ Buffer . from (
61
+ JSON . stringify ( {
62
+ ...user ,
63
+ pay : true ,
64
+ } ) ,
65
+ "utf8"
66
+ )
67
+ ) ,
68
+ {
69
+ httpOnly : false ,
70
+ expires : new Date ( 24 * 60 * 60 * 1000 + Date . now ( ) ) ,
71
+ }
72
+ ) ;
73
+ }
70
74
if ( db . find ( ( q ) => q . login === user . login ) ) {
71
75
ctx . session . user = {
72
76
...user ,
You can’t perform that action at this time.
0 commit comments