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)) user = User.objects.filter(Q(username__iexact=username) | Q(email=username))
if username and user: if username and user:
self.user_cache = authenticate(username=user[0].username, password=password) 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: if self.user_cache is None:
email_username = User.objects.filter(email=username) email_username = User.objects.filter(email=username)
if email_username: if email_username:
self.user_cache = authenticate(username=email_username[0].username, password=password) 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: if self.user_cache is None:
# logging.info(" ***> [%s] Bad Login: TRYING JK-LESS PASSWORD" % username) logging.info(" ***> [%s] Bad Login" % username)
jkless_password = password.replace('j', '').replace('k', '') raise forms.ValidationError(_("Whoopsy-daisy. Try again."))
self.user_cache = authenticate(username=username, password=jkless_password) else:
if self.user_cache is None: # Supreme fuck-up. Accidentally removed the letters J and K from
logging.info(" ***> [%s] Bad Login" % username) # all user passwords. Re-save with correct password.
raise forms.ValidationError(_("Whoopsy-daisy. Try again.")) logging.info(" ***> [%s] FIXING JK-LESS PASSWORD" % username)
else: self.user_cache.set_password(password)
# Supreme fuck-up. Accidentally removed the letters J and K from self.user_cache.save()
# all user passwords. Re-save with correct password. if not self.user_cache.is_active:
logging.info(" ***> [%s] FIXING JK-LESS PASSWORD" % username) raise forms.ValidationError(_("This account is inactive."))
self.user_cache.set_password(password)
self.user_cache.save()
elif not self.user_cache.is_active:
raise forms.ValidationError(_("This account is inactive."))
elif username and not user: elif username and not user:
raise forms.ValidationError(_("That username is not registered. Create an account with it instead.")) 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'): if self.options.get('fake'):
skip = True skip = True
weight = "-" weight = "-"
quick = "-"
rand = "-"
elif self.options.get('quick'): elif self.options.get('quick'):
weight = feed.stories_last_month * feed.num_subscribers weight = feed.stories_last_month * feed.num_subscribers
random_weight = random.randint(1, max(weight, 1)) random_weight = random.randint(1, max(weight, 1))
@ -292,10 +294,11 @@ class Dispatcher:
if random_weight < 100 and rand < quick: if random_weight < 100 and rand < quick:
skip = True skip = True
if skip: 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], unicode(feed)[:30],
weight, weight,
feed.num_subscribers)) feed.num_subscribers,
rand, quick))
continue continue
ffeed = FetchFeed(feed_id, self.options) ffeed = FetchFeed(feed_id, self.options)