def register(): form = uforms.RegisterForm(request.form) if form.validate_on_submit(): user = umodels.User.create(form.username.data, form.password.data) login_user(user) flash.info('Welcome {}.'.format(str(user))) return redirect(request.args.get('next', url_for('app.home'))) return render_template('user/register.html', form=form)
def test_flash_different_categories(self): """Ensure all 4 categories work properly""" success(self.simple_message) warning(self.simple_message) info(self.simple_message) danger(self.simple_message) self.assert_flashes(self.simple_message, 'success') self.assert_flashes(self.simple_message, 'warning') self.assert_flashes(self.simple_message, 'info') self.assert_flashes(self.simple_message, 'danger')
def login(): form = LoginForm(request.form) if request.method == "POST": user = UserHandler.login(form) if user: flash.info('Welcome "{}".'.format(user.username)) return redirect(request.args.get('next', url_for('app.home'))) return render_template('user/login.html', form=form)
def login(): form = LoginForm(request.form) if request.method == "POST": user = UserHandler.login(form) if user: flash.info('Welcome "{}".'.format(user.username)) return redirect(request.args.get('next', url_for('app.home'))) return render_template('user/login.html', form=form)
def test_flash_different_categories(self): """ Ensure all 4 categories work properly """ success(self.simple_message) warning(self.simple_message) info(self.simple_message) danger(self.simple_message) self.assert_flashes(self.simple_message, 'success') self.assert_flashes(self.simple_message, 'warning') self.assert_flashes(self.simple_message, 'info') self.assert_flashes(self.simple_message, 'danger')
def login(): form = uforms.LoginForm(request.form) if request.method == 'POST': if form.validate_on_submit(): user = umodels.User.objects.filter( username=form.username.data).first() if user and check_password_hash(user.password, form.password.data): login_user(user) flash.info('Welcome {}.'.format(str(user))) return redirect(request.args.get('next', url_for('app.home'))) else: flash.warning('Invalid Credentials. Please try again.') return render_template('user/login.html', form=form)
def logout(): logout_user() flash.info('You were logged out.') return redirect(url_for('app.home'))
def settings(): flash.info('Welcome to your dashboard {}.'.format(str(current_user))) return render_template('user/settings.html')
def logout(): UserHandler.logout() flash.info(u'You were logged out.') return redirect(url_for('app.home'))
def settings(): flash.info('Welcome to your dashboard "{}".'.format(current_user.username)) return render_template('user/settings.html')
def logout(): UserHandler.logout() flash.info(u'You were logged out.') return redirect(url_for('app.home'))
def settings(): flash.info('Welcome to your dashboard "{}".'.format(current_user.username)) return render_template('user/settings.html')