Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4b86c40

Browse files
committed
[cookie.chrome] WIP
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent 876f17c commit 4b86c40

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

plugins/cookie.chrome.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
var log = require('../log');
22
var Plugin = require('../plugin');
3+
var session = require('../session');
34

45
// [Usage]
56
//
67
// TODO: still WIP
78
//
8-
var plugin = new Plugin(100, 'cookie.chrome', '2017.12.22',
9+
var plugin = new Plugin(13, 'cookie.chrome', '2017.12.23',
910
'Plugin to reuse Chrome\'s leetcode cookie.',
1011
['keytar', 'sqlite3']);
1112

@@ -101,18 +102,28 @@ Chrome.getCookies = function(cb) {
101102
};
102103

103104
plugin.signin = function(user, cb) {
105+
log.debug('running cookie.chrome.signin');
104106
log.debug('try to copy leetcode cookies from chrome ...');
105107
my.getCookies(function(e, cookie) {
106108
if (e) {
107-
log.error('failed to get cookies: ' + e);
109+
log.error('failed to copy cookies: ' + e);
108110
return plugin.next.signin(user, cb);
109111
}
110112

111113
log.debug('Successfully copied leetcode cookies!');
112114
user.sessionId = cookie.LEETCODE_SESSION;
113115
user.sessionCSRF = cookie.csrftoken;
116+
session.saveUser(user);
114117
return cb(null, user);
115118
});
116119
};
117120

121+
plugin.login = function(user, cb) {
122+
log.debug('running cookie.chrome.login');
123+
plugin.signin(user, function(e, user) {
124+
if (e) return cb(e);
125+
plugin.getUser(user, cb);
126+
});
127+
};
128+
118129
module.exports = plugin;

0 commit comments

Comments
 (0)