def post(self): username = self.request.get('username') password = self.request.get('password') u = User.login(username, password) if u: self.login(u) self.redirect('/api/myfilms') else: msg = 'Invalid login' self.render('/admin/login-form.html', error=msg)
def post(self): username = self.request.get('username') password = self.request.get('password') u = User.login(username, password) if u: self.login(u) self.redirect('/blog') else: msg = 'Invalid login. Try again.' self.render('login-form.html', error=msg, username=username)
def register(): form = FormUser() if form.validate_on_submit(): user = User() user.name = form.name.data user.login = form.login.data user.email = form.email.data user.password = generate_password_hash(form.password.data) db.session.add(user) db.session.commit() return redirect("/users") return render_template("add_user.html", form=form)
def test_login_user(db): assert User.login("test", "password") with pytest.raises(User.IncorrectLoginError) as excinfo: user = User.login("test", "wrong") assert "test" in str(excinfo)