def reset(): form=ResetForm(request.form) if request.method == 'GET': id=int(request.args.get('id')) key=int(request.args.get('key')) if CheckRequest(id,key)==0: flash('The Request is invalid or expired.Please try again.') return redirect(url_for('login')) resp = make_response(render_template('reset.html',form=form)) resp.set_cookie('email',get_email(id)) return resp if request.method == 'POST' and form.validate(): S=BotCheck(request.form.get('g-recaptcha-response')) user=User.query.get(request.cookies.get('email')) if user is None: flash("Entered Email ID is not registered with us.") return render_template('register.html', form=form) if S==False: flash('Invalid Bot Captcha,Please reuse the link.') return redirect(url_for('login')) user.password= form.confirm.data db.session.add(user) db.session.commit() flash('Password changed ,now you can login with you new password') return redirect(url_for('login'))