def signup(): form = SignupForm() if form.validate_on_submit(): user = User(email=form.email.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash('Account is created. Now you can sign in.', 'success') return redirect(url_for('.signin')) return render_template('users/signup.html', form=form)
def signup(): form = SignupForm() if form.validate_on_submit(): user = User(email=form.email.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash('Account is created. Now you can sign in.', 'success') return redirect(url_for('signin')) return render_template('users/signup.html', form=form)
def signin(): form = SigninForm() if form.validate_on_submit(): auth_user = User.authenticate(form.email.data, form.password.data) if auth_user: login_user(auth_user) flash('You are signed in!', 'success') return redirect(url_for('.home')) else: flash('Wrong email or password', 'error') return render_template('users/signin.html', form=form)
def signin(): form = SigninForm() if form.validate_on_submit(): auth_user = User.authenticate(form.email.data, form.password.data) if auth_user: login_user(auth_user) flash('You are signed in!', 'success') return redirect(url_for('home')) else: flash('Wrong email or password', 'error') return render_template('users/signin.html', form=form)
def create_user(self, **kwargs): user = User(email=kwargs['email']) user.set_password(kwargs['password']) db.session.add(user) db.session.commit() return user