- def passwd(self, request, current_password, new_password, new_password_confirm):
- user = request.user
- if user.check_password(current_password) and (new_password == new_password_confirm):
- user.set_password(new_password)
- user.save()
- return True
- return False
+ def get_passwd_form(self, request):
+ from django.contrib.auth.forms import PasswordChangeForm
+ return PasswordChangeForm(request.user).as_ext()
+
+ @gilbert_method(form_handler=True)
+ def submit_passwd_form(self, request):
+ from django.contrib.auth.forms import PasswordChangeForm
+ form = PasswordChangeForm(request.user, data=request.POST)
+ if form.is_valid():
+ form.save()
+ return {'success': True}
+ else:
+ return {'success': False, 'errors': form.errors}