Esempio n. 1
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            return False

        if not User.validate_login(self.login.data):
            self.login.errors.append(gettext('Login already taken'))
            return False

        if not User.validate_email(self.email.data):
            self.email.errors.append(gettext('E-Mail already taken'))
            return False

        return True
Esempio n. 2
0
def login():
    if 'user_id' in session:
        return redirect('/admin/')

    form = UserLoginForm(request.form, next=request.args.get('next'))

    if form.validate_on_submit():
        login = User.login(form.data['login'], form.data['password'])
        if login:
            if form.data['next'] != '':
                return redirect(form.data['next'])
            else:
                return redirect('/admin/')
        else:
            pass
    
    return render_template('admin/login.html', form=form, title="Please sign in")