def register(): form = forms.SignUpInForm() if form.validate_on_submit(): models.User.new( email=form.email.data, password=form.password.data ) flash("Thanks for registering!") return render_template('register.html', form=form)
def register(): form = forms.SignUpInForm() if form.validate_on_submit(): models.User.create_user( email=form.email.data, password=form.password.data ) flash("Thanks for registering!") return redirect(url_for('index'))
def login(): form = forms.SignUpInForm() if form.validate_on_submit(): try: user = models.User.get(models.User.email == form.email.data) if check_password_hash(user.password, form.password.data): login_user(user) flash("You're now logged in!") else: flash("No user with that email/password combo") except models.DoesNotExist: flash("No user with that email/password combo") return render_template('register.html', form=form)
def login(): form = forms.SignUpInForm() email = request.form.get('email') password = request.form.get('password') try: user = models.User.get( models.User.email == email ) if check_password_hash(user.password, password): login_user(user) flash("You're now logged in!") return redirect(url_for('index')) else: flash("No user with that email/password combo") except models.DoesNotExist: flash("No user with that email/password combo") return render_template('login.html', form=form)