Allowing any password to be used on accounts with no password set.

This commit is contained in:
Samuel Clay 2012-02-27 16:36:39 -08:00
parent fcb78b3133
commit 936088f09c
2 changed files with 23 additions and 16 deletions

View file

@ -27,25 +27,29 @@ class LoginForm(forms.Form):
user = User.objects.filter(Q(username__iexact=username) | Q(email=username))
if username and user:
self.user_cache = authenticate(username=user[0].username, password=password)
if self.user_cache is None:
self.user_cache = authenticate(username=user[0].username, password="")
if self.user_cache is None:
email_username = User.objects.filter(email=username)
if email_username:
self.user_cache = authenticate(username=email_username[0].username, password=password)
if self.username is None:
self.user_cache = authenticate(username=email_username[0].username, password="")
if self.user_cache is None:
# logging.info(" ***> [%s] Bad Login: TRYING JK-LESS PASSWORD" % username)
jkless_password = password.replace('j', '').replace('k', '')
self.user_cache = authenticate(username=username, password=jkless_password)
if self.user_cache is None:
# logging.info(" ***> [%s] Bad Login: TRYING JK-LESS PASSWORD" % username)
jkless_password = password.replace('j', '').replace('k', '')
self.user_cache = authenticate(username=username, password=jkless_password)
if self.user_cache is None:
logging.info(" ***> [%s] Bad Login" % username)
raise forms.ValidationError(_("Whoopsy-daisy. Try again."))
else:
# Supreme fuck-up. Accidentally removed the letters J and K from
# all user passwords. Re-save with correct password.
logging.info(" ***> [%s] FIXING JK-LESS PASSWORD" % username)
self.user_cache.set_password(password)
self.user_cache.save()
elif not self.user_cache.is_active:
raise forms.ValidationError(_("This account is inactive."))
logging.info(" ***> [%s] Bad Login" % username)
raise forms.ValidationError(_("Whoopsy-daisy. Try again."))
else:
# Supreme fuck-up. Accidentally removed the letters J and K from
# all user passwords. Re-save with correct password.
logging.info(" ***> [%s] FIXING JK-LESS PASSWORD" % username)
self.user_cache.set_password(password)
self.user_cache.save()
if not self.user_cache.is_active:
raise forms.ValidationError(_("This account is inactive."))
elif username and not user:
raise forms.ValidationError(_("That username is not registered. Create an account with it instead."))

View file

@ -284,6 +284,8 @@ class Dispatcher:
if self.options.get('fake'):
skip = True
weight = "-"
quick = "-"
rand = "-"
elif self.options.get('quick'):
weight = feed.stories_last_month * feed.num_subscribers
random_weight = random.randint(1, max(weight, 1))
@ -292,10 +294,11 @@ class Dispatcher:
if random_weight < 100 and rand < quick:
skip = True
if skip:
logging.debug(' ---> [%-30s] ~BGFaking fetch, skipping (%s/month, %s subs)...' % (
logging.debug(' ---> [%-30s] ~BGFaking fetch, skipping (%s/month, %s subs, %s < %s)...' % (
unicode(feed)[:30],
weight,
feed.num_subscribers))
feed.num_subscribers,
rand, quick))
continue
ffeed = FetchFeed(feed_id, self.options)