|
5 | 5 | from roundup.i18n import _ |
6 | 6 | from roundup.cgi import exceptions, templating |
7 | 7 | from roundup.mailgw import uidFromAddress |
8 | | -from roundup.rate_limit import Store, RateLimit |
| 8 | +from roundup.rate_limit import Gcra, RateLimit |
9 | 9 | from roundup.exceptions import Reject, RejectRaw |
10 | 10 | from roundup.anypy import urllib_ |
11 | 11 | from roundup.anypy.strings import StringIO |
@@ -1235,27 +1235,27 @@ def handle(self): |
1235 | 1235 | # Use prefix to prevent key collisions maybe?? |
1236 | 1236 | rlkey="LOGIN-" + self.client.user |
1237 | 1237 | limit=self.loginLimit |
1238 | | - s=Store() |
| 1238 | + gcra=Gcra() |
1239 | 1239 | otk=self.client.db.Otk |
1240 | 1240 | try: |
1241 | 1241 | val=otk.getall(rlkey) |
1242 | | - s.set_tat_as_string(rlkey, val['tat']) |
| 1242 | + gcra.set_tat_as_string(rlkey, val['tat']) |
1243 | 1243 | except KeyError: |
1244 | 1244 | # ignore if tat not set, it's 1970-1-1 by default. |
1245 | 1245 | pass |
1246 | 1246 | # see if rate limit exceeded and we need to reject the attempt |
1247 | | - reject=s.update(rlkey, limit) |
| 1247 | + reject=gcra.update(rlkey, limit) |
1248 | 1248 |
|
1249 | 1249 | # Calculate a timestamp that will make OTK expire the |
1250 | 1250 | # unused entry 1 hour in the future |
1251 | 1251 | ts = time.time() - (60 * 60 * 24 * 7) + 3600 |
1252 | | - otk.set(rlkey, tat=s.get_tat_as_string(rlkey), |
| 1252 | + otk.set(rlkey, tat=gcra.get_tat_as_string(rlkey), |
1253 | 1253 | __timestamp=ts) |
1254 | 1254 | otk.commit() |
1255 | 1255 |
|
1256 | 1256 | if reject: |
1257 | 1257 | # User exceeded limits: find out how long to wait |
1258 | | - status=s.status(rlkey, limit) |
| 1258 | + status=gcra.status(rlkey, limit) |
1259 | 1259 | raise Reject(_("Logins occurring too fast. Please wait: %d seconds.")%status['Retry-After']) |
1260 | 1260 | else: |
1261 | 1261 | self.verifyLogin(self.client.user, password) |
|
0 commit comments