Commit 7a4831cffabe882e322dfb1e6c08957472ff153c
1 parent
53de9493
Exists in
master
and in
39 other branches
Minor fixes and refactoring
Showing
2 changed files
with
2 additions
and
9 deletions
Show diff stats
src/accounts/models.py
@@ -23,20 +23,14 @@ class User(AbstractUser): | @@ -23,20 +23,14 @@ class User(AbstractUser): | ||
23 | modified = models.DateTimeField(auto_now=True) | 23 | modified = models.DateTimeField(auto_now=True) |
24 | 24 | ||
25 | def check_password(self, raw_password): | 25 | def check_password(self, raw_password): |
26 | - """ | ||
27 | - Returns a boolean of whether the raw_password was correct. Handles | ||
28 | - hashing formats behind the scenes. | ||
29 | - """ | ||
30 | - def setter(raw_password): | ||
31 | - self.set_password(raw_password) | ||
32 | - self.save(update_fields=["password"]) | 26 | + is_correct_ = super(User, self).check_password(raw_password) |
33 | 27 | ||
34 | if self.xmpp.exists(): | 28 | if self.xmpp.exists(): |
35 | is_correct = raw_password == self.xmpp.all()[0].password | 29 | is_correct = raw_password == self.xmpp.all()[0].password |
36 | if is_correct: | 30 | if is_correct: |
37 | return is_correct | 31 | return is_correct |
38 | 32 | ||
39 | - return check_password(raw_password, self.password, setter) | 33 | + return is_correct_ |
40 | 34 | ||
41 | def get_absolute_url(self): | 35 | def get_absolute_url(self): |
42 | return reverse('user_profile', kwargs={'username': self.username}) | 36 | return reverse('user_profile', kwargs={'username': self.username}) |
src/accounts/views.py
@@ -212,7 +212,6 @@ class ChangeXMPPPasswordView(UpdateView): | @@ -212,7 +212,6 @@ class ChangeXMPPPasswordView(UpdateView): | ||
212 | return response | 212 | return response |
213 | else: | 213 | else: |
214 | self.request.user.set_password(form.cleaned_data['password1']) | 214 | self.request.user.set_password(form.cleaned_data['password1']) |
215 | - self.request.user.save() | ||
216 | transaction.commit() | 215 | transaction.commit() |
217 | 216 | ||
218 | messages.success( | 217 | messages.success( |