From 7a4831cffabe882e322dfb1e6c08957472ff153c Mon Sep 17 00:00:00 2001 From: Luan Date: Thu, 28 Nov 2013 10:39:45 -0200 Subject: [PATCH] Minor fixes and refactoring --- src/accounts/models.py | 10 ++-------- src/accounts/views.py | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/accounts/models.py b/src/accounts/models.py index 22e5b9d..aece67c 100644 --- a/src/accounts/models.py +++ b/src/accounts/models.py @@ -23,20 +23,14 @@ class User(AbstractUser): modified = models.DateTimeField(auto_now=True) def check_password(self, raw_password): - """ - Returns a boolean of whether the raw_password was correct. Handles - hashing formats behind the scenes. - """ - def setter(raw_password): - self.set_password(raw_password) - self.save(update_fields=["password"]) + is_correct_ = super(User, self).check_password(raw_password) if self.xmpp.exists(): is_correct = raw_password == self.xmpp.all()[0].password if is_correct: return is_correct - return check_password(raw_password, self.password, setter) + return is_correct_ def get_absolute_url(self): return reverse('user_profile', kwargs={'username': self.username}) diff --git a/src/accounts/views.py b/src/accounts/views.py index a8262f8..3fad1cd 100644 --- a/src/accounts/views.py +++ b/src/accounts/views.py @@ -212,7 +212,6 @@ class ChangeXMPPPasswordView(UpdateView): return response else: self.request.user.set_password(form.cleaned_data['password1']) - self.request.user.save() transaction.commit() messages.success( -- libgit2 0.21.2