Skip to content

Commit

Permalink
fix(token): add extra time to deal with some critical condtions
Browse files Browse the repository at this point in the history
  • Loading branch information
defclass authored and tiensonqin committed Dec 2, 2020
1 parent 0dfbc31 commit bbf76eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/main/frontend/helper.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
(if (and (map? token-state)
(string? expires_at))
(let [expires-at (tf/parse (tf/formatters :date-time-no-ms) expires_at)
request-time-gap (t/minutes 5)
now (t/now)
expired? (t/after? now (t/minus expires-at request-time-gap))]
expired? (t/after? now expires-at)]
{:exist? true
:expired? expired?
:token token})
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/state.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@
(if (string? token)
;; Github API returns a expires_at key which is a timestamp (expires after 60 minutes at present),
;; however, user's system time may be inaccurate. Here, based on the client system time, we use
;; 60-minutes duration directly.
;; 40-minutes interval to deal with some critical conditions, for e.g. http request time consume.
(let [formatter (tf/formatters :date-time-no-ms)
expires-at (->> (t/plus (t/now) (t/minutes 60))
expires-at (->> (t/plus (t/now) (t/minutes 40))
(tf/unparse formatter))]
(merge repo {:token token :expires_at expires-at}))
(do (log/error :token/cannot-set-token {:repo-m repo :token-m m}) repo))))
Expand Down

0 comments on commit bbf76eb

Please sign in to comment.