def mail_verified(): form = MailVerifiedForm( mail_verification=request.args.get('mail_verification')) if form.validate_on_submit(): user = User.deserialize_token(request.form.get('mail_verification')) if user is None: flash('Your mail verification has expired or was tampered with.', 'danger') return redirect(url_for('users.login_user')) user.email_valid = True user.update_user() flash('Your E-mail address has been verified', 'success') return redirect(url_for('users.login_user')) return render_template('mail_verification.html', form=form)
def password_reset(): form = PasswordResetForm(reset_token=request.args.get('reset_token')) if form.validate_on_submit(): user = User.deserialize_token(request.form.get('reset_token')) if user is None: flash('Your reset token has expired or was tampered with.', 'danger') return redirect(url_for('users.password_reset_trigger')) form.populate_obj(user) hashed_password = User( email='None', password=request.form.get('password') ).password # hack to encrypt a password. by running init user.password = hashed_password user.update_user() flash('Your password has been reset.', 'success') return redirect(url_for('users.login_user')) return render_template('password_reset.html', form=form)