示例#1
0
 def post(self, request, *args, **kwargs):
     error, errors = "", ""
     form = ChangePasswordForm(request.POST, user=request.user)
     if form.is_valid():
         user = request.user
         user.set_password(request.POST.get('Newpassword'))
         user.is_active = True
         user.save()
         return HttpResponseRedirect('inventory:landing_index')
     else:
         errors = form.errors
     return render(request, "change_password.html",
                   {'error': error, 'errors': errors,
                    'change_password_form': form})
示例#2
0
 def post(self, request, *args, **kwargs):
     error, errors = "", ""
     form = ChangePasswordForm(request.POST)
     if form.is_valid():
         user = request.user
         if not check_password(request.POST.get('CurrentPassword'), user.password):
             error = "Invalid old password"
         else:
             user.set_password(request.POST.get('Newpassword'))
             user.is_active = True
             user.save()
             return HttpResponseRedirect('/')
     else:
         errors = form.errors
     return render(request, "change_password.html", {'error': error, 'errors': errors})
示例#3
0
def change_pass(request):
    error, errors = "", ""
    form = ChangePasswordForm()
    if request.method == 'POST':
        form = ChangePasswordForm(request.POST)
        if form.is_valid():
            user = request.user
            if not check_password(request.POST['CurrentPassword'], user.password):
                error = "Invalid old password"
            else:
                user.set_password(request.POST.get('Newpassword'))
                user.is_active = True
                user.save()
                return HttpResponseRedirect('/')
        else:
            errors = form.errors
    return render(request, "change_password.html", {'error': error,
                                                    'errors': errors})