本文整理汇总了Python中forms.ChangePasswordForm.validate方法的典型用法代码示例。如果您正苦于以下问题:Python ChangePasswordForm.validate方法的具体用法?Python ChangePasswordForm.validate怎么用?Python ChangePasswordForm.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.ChangePasswordForm
的用法示例。
在下文中一共展示了ChangePasswordForm.validate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: change_password
# 需要导入模块: from forms import ChangePasswordForm [as 别名]
# 或者: from forms.ChangePasswordForm import validate [as 别名]
def change_password():
form = ChangePasswordForm(request.form)
if request.method == "POST" and form.validate():
user = User.query.filter_by(name=g.user.name).first()
user.password = hash_str(form.password.data)
user.save()
return redirect(url_for('user.settings'))
return redirect(url_for('user.settings'))
示例2: change_password
# 需要导入模块: from forms import ChangePasswordForm [as 别名]
# 或者: from forms.ChangePasswordForm import validate [as 别名]
def change_password():
if( request.method == "POST"):
form = ChangePasswordForm( request.form)
if( form.validate()):
current_user.set_password( form.password1.data)
flash( "Your password was changed successfully.", "success")
return redirect( "/")
else:
form = ChangePasswordForm()
return render_template( "auth/change_password.html", **locals())
示例3: changepassword
# 需要导入模块: from forms import ChangePasswordForm [as 别名]
# 或者: from forms.ChangePasswordForm import validate [as 别名]
def changepassword():
form = ChangePasswordForm(request.form)
if request.method == "POST" and form.validate():
if not current_user.check_password(form.old_password.data):
form.old_password.errors.append(u"密码错误!")
return render_template("changepassword.html", form=form)
current_user.password = User.create_password(form.new_password.data)
db.session.add(current_user)
db.session.commit()
flash(u"密码修改成功!")
return render_template("changepassword.html", form=ChangePasswordForm())
return render_template("changepassword.html", form=form)
示例4: change_password
# 需要导入模块: from forms import ChangePasswordForm [as 别名]
# 或者: from forms.ChangePasswordForm import validate [as 别名]
def change_password():
'''
Change a user's password
'''
form = ChangePasswordForm(request.form)
if request.method == 'POST' and form.validate():
if current_user.check_password(form.old_password.data):
current_user.update_password(form.new_password.data)
current_user.save()
flash("Your password has been updated.", category='index_page')
return redirect(url_for('.list_projects'))
else:
flash("Your password does not match.", category='error')
return render_template('change_password.html', form=form)
return render_template('change_password.html', form=form)
示例5: changepassword
# 需要导入模块: from forms import ChangePasswordForm [as 别名]
# 或者: from forms.ChangePasswordForm import validate [as 别名]
def changepassword():
form = ChangePasswordForm()
if 'Members_Email' not in session:
return redirect(url_for('signin'))
if request.method == 'POST':
if form.validate() == False:
return render_template('changepassword.html', form=form)
else:
test = User.query.filter_by(Members_Email = session['Members_Email']).first()
test.Members_Passhash = update_password(form.Members_Password.data)
db.session.add(test)
db.session.commit()
return redirect(url_for('profile'))
elif request.method == 'GET':
return render_template('changepassword.html', form=form)
示例6: post
# 需要导入模块: from forms import ChangePasswordForm [as 别名]
# 或者: from forms.ChangePasswordForm import validate [as 别名]
def post(self):
old_password = self.get_argument("old_password")
new_password = self.get_argument("new_password")
confirm_password = self.get_argument("confirm_password")
form = ChangePasswordForm(self.request.arguments)
password_error = password_validation(self.session, self.uid,
old_password)
if form.validate():
if password_error == "":
change_password(self.session, self.uid, new_password)
self.redirect("/")
else:
self.render("changepassword.html", username=self.username,
group=self.group, form=form, db_error=password_error)
else:
self.render("changepassword.html", username=self.username,
group=self.group, form=form, db_error=None)