Просмотр исходного кода

Set tokens to expire 5 minutes early

Prevents occasional usage of tokens the very second they expire
Zed 4 лет назад
Родитель
Сommit
3d91ae0256
2 измененных файлов с 1 добавлено и 16 удалено
  1. 0 15
      src/experimental/types/common.nim
  2. 1 1
      src/tokens.nim

+ 0 - 15
src/experimental/types/common.nim

@@ -7,21 +7,6 @@ type
     displayUrl*: string
     indices*: array[2, int]
 
-  ErrorCode* = enum
-    null = 0
-    noUserMatches = 17
-    protectedUser = 22
-    couldntAuth = 32
-    doesntExist = 34
-    userNotFound = 50
-    suspended = 63
-    rateLimited = 88
-    invalidToken = 89
-    listIdOrSlug = 112
-    forbidden = 200
-    badToken = 239
-    noCsrf = 353
-
   ErrorObj* = object
     code*: Error
     message*: string

+ 1 - 1
src/tokens.nim

@@ -6,8 +6,8 @@ import types, agents, consts, http_pool
 
 const
   maxConcurrentReqs = 5  # max requests at a time per token, to avoid race conditions
-  maxAge = 3.hours       # tokens expire after 3 hours
   maxLastUse = 1.hours   # if a token is unused for 60 minutes, it expires
+  maxAge = 2.hours + 55.minutes  # tokens expire after 3 hours
   failDelay = initDuration(minutes=30)
 
 var