66; ; Keywords: extensions, tools
77; ; URL: https://github.com/kaiwk/leetcode.el
88; ; Package-Requires: ((emacs "26") (dash "2.16.0") (graphql "0.1.1") (spinner "1.7.3") (aio "1.0") (log4e "0.3.3"))
9- ; ; Version: 0.1.16
9+ ; ; Version: 0.1.17
1010
1111; ; This program is free software; you can redistribute it and/or modify
1212; ; it under the terms of the GNU General Public License as published by
@@ -224,11 +224,12 @@ VALUE should be the referer."
224224 (" filename" . " " )
225225 (" content-type" . " " )))
226226
227- (defun leetcode--login ()
227+ (aio- defun leetcode--login ()
228228 " Steal LeetCode login session from local browser.
229229It also cleans LeetCode cookies in `url-cookie-file' ."
230230 (leetcode--loading-mode t )
231231 (ignore-errors (url-cookie-delete-cookies leetcode--domain))
232+ (aio-await (leetcode--csrf-token)) ; knock knock, whisper me the mysterious information
232233 (let* ((my-cookies (executable-find " my_cookies" ))
233234 (my-cookies-output (shell-command-to-string my-cookies))
234235 (cookies-list (seq-filter
@@ -239,7 +240,8 @@ It also cleans LeetCode cookies in `url-cookie-file'."
239240 cookies-list))
240241 (leetcode-session (cadr (assoc " LEETCODE_SESSION" cookies-pairs)))
241242 (leetcode-csrftoken (cadr (assoc " csrftoken" cookies-pairs))))
242- (leetcode--debug " login: %s" my-cookies-output)
243+ (leetcode--debug " login session: %s" leetcode-session)
244+ (leetcode--debug " login csrftoken: %s" leetcode-csrftoken)
243245 (url-cookie-store " LEETCODE_SESSION" leetcode-session nil leetcode--domain " /" t )
244246 (url-cookie-store " csrftoken" leetcode-csrftoken nil leetcode--domain " /" t ))
245247 (leetcode--loading-mode -1 ))
@@ -546,7 +548,7 @@ Return a list of rows, each row is a vector:
546548 (if (get-buffer leetcode--buffer-name)
547549 (switch-to-buffer leetcode--buffer-name)
548550 (unless (leetcode--login-p)
549- (leetcode--login))
551+ (aio-await ( leetcode--login) ))
550552 (aio-await (leetcode-refresh-fetch))
551553 (switch-to-buffer leetcode--buffer-name)))
552554
0 commit comments