def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash('An email has been sent with instructions to reset your password.', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'An email has been sent with instructions to reset your password.', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() #TODO Handle Exception Case send_reset_email(user) flash(f'An email with the reset link has been sent to your account.', 'success') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for("main.home_page")) form = RequestResetForm() # Handling if the form was submitted and validated if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( "An email has been sent to reset your password. Please follow the instructions given in the mail.", "info", ) return redirect(url_for("users.login")) return render_template("reset_request.html", title="Reset Password", form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for("main.home")) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( "An email has been sent with instructions to reset your password", "info") return redirect(url_for("users.login")) return render_template("reset_request.html", title="Reset Password", form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): for query in User.objects(email=form.email.data): user = query send_reset_email(user) flash( "An email has been sent with instructions to reset your password", "info") return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: flash('Please Logout first to reset your password.', 'danger') return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'Email has been sent plese go to your mail for further instruction', 'success') return redirect(url_for('users.login')) return render_template('request_reset.html', form=form, title='Request Password Reset')
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'Un email se ha enviado con instrucciones para cambiar la contraseña', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', form=form, title='Resetear Contraseña')
def reset_request(): # If user is logged in then redirect to home page if current_user.is_authenticated: return redirect(url_for("main.home")) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( "An email has been sent to your email with instructions for resetting password", "info") return redirect(url_for('users.login')) return render_template( 'reset_request.html', form=form, title='Reset Request') # posts variable is passed having value post
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() ## flash("Google doesn't allow me to send email through their server for now, sorry.",'danger') send_reset_email(user) flash( 'An email with instructions to reset your password has been sent to your email address!', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Forget Password', form=form)
def reset_request(): #To make sure that the user is logged out. if current_user.is_authenticated: return redirect(url_for('home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( "An email containing instructions on how to reset your password has been sent.", 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash('E-mail enviado. Confira sua caixa de entrada', 'info') return redirect(url_for('users.login')) return render_template( 'reset_request.html', title='Recuperar senha', form=form )
def request_reset(): ##如果用户已经认证,则转到主页 if current_user.is_authenticated: return redirect(url_for('main.home')) form = ResetRequestForm() if form.validate_on_submit(): ##表格提交后,根据邮件地址查找用户对象 user = User.query.filter_by(email=form.email.data).first() ##发邮件 send_reset_email(user) flash('A Email with instruction has been sent to your email', 'success') return redirect(url_for('users.login')) return render_template('request_reset.html', title='Password Reset', form=form)
def reset_request(): # if user is already logged in, redirect to the home page if current_user.is_authenticated: return redirect(url_for('users.home')) # if the user is not logged in, they can access the password request form form = RequestPasswordReset() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'An email has been sent with instructions to reset your password easily', 'info') return redirect(url_for('users.login')) return render_template('request_password_reset.html', title='Reset Password', form=form, legend='Reset Password')
def reset_request(): if current_user.is_authenticated: flash('Must be logged out in order to request for password reset', 'secondary') return redirect(url_for('main.home_page')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'Instructions on how to reset your password has been sent to your email', 'info') return redirect(url_for('users.user_login_page')) return render_template('reset_request.html', title='Password Reset Request', form=form)
def reset_request(): """Request password reset""" # The user must be logged out to get to the form if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() # since forms will return to forms they're sent from we add submet-validation here if form.validate_on_submit(): # get the user user = User.query.filter_by(email=form.email.data).first() # send email to user send_reset_email(user) flash('An email has been sent with reset instructions.', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def request_reset_password(): if current_user.is_authenticated: return redirect(url_for('users.profile')) form = ResetPasswordRequest() if form.validate_on_submit(): if form.checkEmail(form.email.data): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'An email with instruction to reset your password has been sent', 'info') return redirect(url_for('users.login')) else: pass return render_template('reset_password_request.html', form=form, title='Reset Password Request')
def request_reset_password(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = ResetRequestForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() try: send_reset_email(user) except: flash('This serice is currently unavailable', 'danger') return redirect(url_for('users.request_reset_password')) flash('Instruction to reset password has been sent to your email.', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def set_reset_request(): # (1)如果用户已登录,进入url:"/reset_password"将直接重定向至set_home的页面 ----- 需要去掉已登录就不让修改密码的情况,因为我们在account页面也要增加重置密码功能 # if current_user.is_authenticated: # return redirect(url_for("main.set_home")) # (2)如果用户未登录,进入提交重置密码请求的页面,用户填写request_form表单 request_form = RequestResetForm() # 用户填完表单数据,点击submit按钮,即发送了POST请求,根据RequestResetForm中定义好的验证方法来验证email信息 if request_form.validate_on_submit(): user = User.query.filter_by(email=request_form.email.data).first() send_reset_email(user) flash("重置密码的邮件已发送至您的邮箱,请查收!", "info") if current_user.is_authenticated: return redirect(url_for("users.set_account")) else: return redirect(url_for("users.set_login")) return render_template("reset_request.html", title="重置密码", request_form=request_form)
def reset_request(): latest_posts = Post.query.order_by(Post.date_posted.desc()).limit(6).all() top_rated_posts = Post.query.outerjoin(Upvote_association).group_by( Post.id).order_by(func.count().desc()).limit(6).all() if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'An email has been sent to your registered email id for resetting your password' ) return render_template('reset_request.html', title='Reset Password', form=form, top_rated_posts=top_rated_posts, latest_posts=latest_posts)
def reset_request(): """ The route that leads to the reset_request.html page. This route has the user enter the email of their account, which is then sent an email with a link to reset the password. """ if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'An email has been sent with instructions to reset your password.', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): languages = current_app.config['LANGUAGES'] locale = list(languages)[0] if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( _('An email has been sent with instructions to reset your password.' ), 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form, languages=languages, locale=locale, _l=_l)
def reset_request(): """ TO send the email to reset password :return: if authenticated, redirect to homepage if form is submitted, redirect to user login At default, render reset_request.html, title, form """ if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() # send email send_reset_email(user) flash('An email has been sent with instructions to reset' 'your password.', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def recover_account(): # redirect to home if user already logged in if current_user.is_authenticated: return redirect(url_for('main.home')) form = RecoverAccount() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( f'An email has been sent with the instructions to reset the Password.', 'info') return redirect(url_for('users.login')) return render_template('recover_account.html', title='Recover Account', form=form)
def reset_request(): if current_user.is_authenticated: # if user is already logged in return redirect(url_for("main.home")) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user: send_reset_email(user) flash( 'If an account with this email address exists, an email has been sent with instructions to the specified email.', "info") return redirect(url_for("users.login")) else: flash( 'If an account with this email address exists, an email has been sent with instructions to the specified email.', "info") return redirect(url_for("users.login")) return render_template("reset_request.html", title="reset password", form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() try: send_reset_email(user) flash( 'An email has been sent with instructions to reset your password.', 'info') return redirect(url_for('users.login')) except: flash( 'An email could not be sent with instructions to reset your password. Redirecting to password reset link', 'warning') return redirect( url_for('users.reset_token', token=user.get_reset_token())) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if 'user' in session: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = Users() user = user.query_email(email=form.email.data) if len(user) == 0: flash('Your account does not exist', 'error') return redirect(url_for('users.reset_password')) email = user[0]['email'] username = user[0]['username'] image_file = user[0]['image_file'] user = User(email=email, username=username, image_file=image_file) #user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'An email has been sent with instructions to reset your password.', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): #This if is to make sure that user is "LOG OUT" before reseting their password if current_user.is_authenticated: return redirect( url_for('main.home') ) #if user is "LOG IN" then redirect to home page (only user that is not "LOG IN" can reset password) form = RequestResetForm() #create instance of our RequestResetForm #After we created our form we need to validate if the submited form was correct if (form.validate_on_submit()): #At that point user submited email in the form so lets check if we have user for such email in db user = User.query.filter_by(email=form.email.data).first( ) # .first() means that we need first user with that email #Now we are going to send email to that user with a token that they can use to reset their password send_reset_email(user) flash( 'An email has been sent with instructions to reset your password', 'info') #Add flash message that will tell user that #Now redirect user to 'login' webpage return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form) #render the template
def reset_request(): # Make sure user is logged out to view this # Check if user is already logged in with current_user variable from flask login module downloaded if current_user.is_authenticated: return redirect('home') # GET request, Initialize form to be filled on reset_token.html wich will be sent to user email on form submit form = RequestResetForm() # If form was submitted with POST request and validated if form.validate_on_submit(): # Get user data from form and check database for the user information user = User.query.filter_by(email=form.email.data).first() # Use function created above to send the user an email with the token url to reset their password send_reset_email(user) # Successful email sent with instructions flash('An email has been sent with instructions to reset your password', 'info') # Redirect back to login page return redirect(url_for('users.login')) # Get request show reset password token form return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if send_reset_email(user): flash( 'An email has been sent with instructions to reset your password.', 'info') return redirect(url_for('users.login')) else: flash( 'We could not deliver email with reset instructions to you.' ' Try again later.', 'danger') return redirect(url_for('users.reset_request')) return render_template("users/reset_request.html", title="Reset Password", form=form)