Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
    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)
Esempio n. 4
0
    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)
Esempio n. 5
0
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)