Exemplo n.º 1
0
    def get(self):

        form = LoginForm()

        if form.validate_on_submit():
            user = User.query.filter_by(username=form.username.data).first()

            if user and user.check_password(form.password.data):
                    session.regenerate()
                    login_user(user, remember=form.remember_me.data)

                    return redirect(url_for('root'))
            else:
                form.password.errors.append('The username or password is incorrect.')

        return render_template('pages/login.html', form=form)
Exemplo n.º 2
0
    def get(self):

        form = LoginForm()

        if not self.app.config['RECAPTCHA_PRIVATE_KEY']:
            delattr(form, 'recaptcha')

        if form.validate_on_submit():
            user = User.query.filter_by(username=form.username.data).first()

            if user and user.check_password(form.password.data):
                    session.regenerate()
                    login_user(user, remember=form.remember_me.data)

                    return redirect(url_for('root'))
            else:
                form.password.errors.append('The username or password is incorrect.')

        return render_template('pages/login.html', form=form, register_enabled=self.app.config['REGISTER_ENABLED'])
Exemplo n.º 3
0
    def get(self):

        form = LoginForm()

        if not self.app.config['RECAPTCHA_PRIVATE_KEY']:
            delattr(form, 'recaptcha')

        if form.validate_on_submit():
            user = User.query.filter_by(username=form.username.data).first()

            if user and user.check_password(form.password.data):
                session.regenerate()
                login_user(user, remember=form.remember_me.data)

                return redirect(url_for('root'))
            else:
                form.password.errors.append(
                    'The username or password is incorrect.')

        return render_template(
            'pages/login.html',
            form=form,
            register_enabled=self.app.config['REGISTER_ENABLED'])