def change_pwd(): form = ChangePassword() if form.validate_on_submit(): if current_user.verity_password(form.old_password.data): current_user.password = form.password.data flash('Password modification succeeded') return redirect(url_for('main.index')) flash('Original password error') return render_template('auth/changePwd.html', form=form)
def change_email(): form = ChangeEmailForm() if form.validate_on_submit(): if current_user.verity_password(form.password.data): current_user.email = form.new_email.data db.session.add(current_user) db.session.commit() flash(u'邮箱已更改!') return redirect(url_for('main.index')) return render_template('auth/change_email.html', form=form)
def change_password(): form = ChangePasswordForm() if form.validate_on_submit(): if current_user.verity_password(form.old_password.data): current_user.password = form.password.data db.session.add(current_user) flash('Your password has been updated') return redirect(url_for('main.index')) else: flash('Invalid password') return render_template('auth/change_password.html', form=form)
def change_password(): form = ChangePasswordForm() if form.validate_on_submit(): if current_user.verity_password(form.old_password.data): current_user.password = form.new_password.data db.session.add(current_user) db.session.commit() flash(u'密码已更改!') return redirect(url_for('auth.logout')) else: flash(u'密码错误!') return render_template('auth/change_password.html', form=form)
def Change_Password(): form = Change_PasswordForm() if form.validate_on_submit(): if current_user.verity_password(form.old_password.data): current_user.password = form.new_password.data db.session.add(current_user) db.session.commit() flash(u'密码重设成功') else: flash(u'重设失败') return redirect(url_for('main.index')) return render_template('auth/changpassword.html', form=form)
def cheage_password(): form = CheagePwdForm() if form.validate_on_submit(): print(current_user) if current_user.verity_password(form.old_pwd.data): current_user.password = form.new_pwd.data db.session.add(current_user) db.session.commit() logout_user() flash("修改密码成功,请重新登陆", "ok") return redirect(url_for('user.login')) else: flash("原始密码有误", "err") return redirect(url_for('user.cheage_password')) return render_template("user/cheage_password.html", form=form)
def change_email(): form = ChangeEmail() if form.validate_on_submit(): if current_user.verity_password(form.password.data): email = form.email.data token = current_user.generate_confirmation_token(email=email) send_mail(email, 'Confirm to modify your account', 'auth/email/comfirm_email', user=current_user, token=token) flash('A confirmation email has been sent to you by email.') else: flash('Password error') return redirect(url_for('main.index')) return render_template('auth/changeEmail.html', form=form)
def reset_mail(): form = Reset_MailForm() if form.validate_on_submit(): if current_user.verity_password(form.password.data): new_email = form.email2.data token = current_user.change_mail(new_email) send_email(current_user.email, u'修改邮箱', 'auth/email/change_email', user=current_user, token=token) flash(u'邮件发送成功') return redirect(url_for('auth.login')) else: flash(u'密码或邮箱错误') return render_template('auth/reset_mail.html', form=form)
def change_email_request(): form = ChangeEmailForm() if form.validate_on_submit(): if current_user.verity_password(form.password.data): new_email = form.email.data token = current_user.generate_email_change_token(new_email) send_email_async(new_email, 'Confirm your email address', 'auth/email/change_email', user=current_user, token=token) flash( "An email with instructions to confirm your new address has been sent to you." ) return redirect(url_for('main.index')) else: flash("Invalid email or password.") return render_template("auth/change_email.html", form=form)