def reset_request(token): if current_user.is_authenticated: return 'you need to logout to access this page' form = PasswordResetForm() user = User.verify_serializer_token(token, salt='password reset') if user: if form.validate_on_submit(): user.set_password(form.password.data) db.session.commit() return redirect(url_for('user.login')) return render_template('password_reset.html', form=form) else: return redirect(url_for('user.reset')) return "password Reset Request"
def signup(): if current_user.is_authenticated: return 'you need to logout to access this page' form = SignupForm() if form.validate_on_submit(): user = User(name=form.name.data, username=form.username.data, email=form.email.data) user.set_password(form.password.data) db.session.add(user) user.self_follow db.session.commit() return redirect(url_for('user.confirm')) return render_template('signup.html', form=form)
def signup(): if current_user.is_authenticated: return 'you need to logout to access this page' form = SignupForm() if form.validate_on_submit(): user = User(name=form.name.data, username=form.username.data, email=form.email.data) user.set_password(form.password.data) db.session.add(user) user.self_follow db.session.commit() login_user(user, remember=True) flash( f'Account has been created for { user.username } please confirm your e-mail', 'success') return redirect(url_for('user.confirm')) return render_template('signup.html', form=form)
def reset_request(token): if current_user.is_authenticated: flash("You need to logout to access this page", "warning") return redirect(url_for('main.home')) form = PasswordResetForm() user = User.verify_serializer_token(token, salt='password reset') if user: if form.validate_on_submit(): user.set_password(form.password.data) db.session.commit() flash("password has been reset. Login with new password", "success") return redirect(url_for('user.login')) return render_template('password_reset.html', form=form) else: flash("Error in reseting password try again", "danger") return redirect(url_for('user.reset')) flash("Password Reset mail has been send check your inbox", "info") return redirect(url_for('user.login'))