def login(): form = LoginForm() if request.method == 'POST': if form.validate_on_submit(): user, authenticated = User.authenticate(form.username.data, form.password.data) if user and authenticated: login_user(user, remember=form.remember_me.data) flash('Logged successfully %s' % current_user.username, 'success') return redirect(url_for('devices.devices_list')) flash("Wrong Username or Password.", "danger") print 'Wrong Username' return render_template('auth/login.html', title='Sign In', form=form)
def save(self): return User.create_user(self.username.data, self.password.data)