Example #1
0
 def test_confirm_is_required(self):
     data = {
         "old": "old",
         "new": "new",
     }
     form = ChangePasswordForm(data)
     self.assertFalse(form.is_valid())
Example #2
0
 def test_form_is_valid(self):
     data = {
         "old": "old",
         "new": "new",
         "confirm": "new",
     }
     form = ChangePasswordForm(data)
     self.assertTrue(form.is_valid())
Example #3
0
def change_password_post():
    form = ChangePasswordForm(request.form)
    user = g.user
    if form.validate():
        if check_password_hash(user.password, form.old_password.data):
            password = generate_password_hash(form.password.data)
            user.password = password
            db.session.commit()
            flash('Hasło zostało zmienione', 'success')
            return redirect(url_for('auth.dashboard'))
    return render_template('pages/change_password.html', form=form)
Example #4
0
def change_password():
    form = ChangePasswordForm(obj=g.user)
    return render_template('pages/change_password.html', form=form)