blog/app/routes.py
def login():
    """ We handle admin panel logins here. """

    form = LoginForm()
    if form.validate_on_submit():

        def fail():
            flask.flash("Invalid username or password")
            return flask.redirect(flask.url_for('login'))

        try:
            user_obj = models.User(email=form.email.data)
        except Exception as e:  # unknown user
            return fail()

        if not user_obj.check_password(form.password.data):
            return fail()
        else:
            # success--log the user in!
            user_obj.logger.info('User authenticated! %s' % user_obj)
            flask_login.login_user(user_obj, remember=form.remember_me.data)
            next_page = flask.request.args.get('next')
            if not next_page or url_parse(next_page).netloc != '':
                next_page = flask.url_for('admin')
            return flask.redirect(next_page)

    return flask.render_template('login.html', form=form)
 We handle admin panel logins here. 
We handle admin panel logins here.
We handle admin panel logins here .
def login():
    form = LoginForm()
    if form.validate_on_submit():
        def fail():
            flask.flash("Invalid username or password")
            return flask.redirect(flask.url_for('login'))
        try:
            user_obj = models.User(email=form.email.data)
        except Exception as e:  
            return fail()
        if not user_obj.check_password(form.password.data):
            return fail()
        else:
            user_obj.logger.info('User authenticated! %s' % user_obj)
            flask_login.login_user(user_obj, remember=form.remember_me.data)
            next_page = flask.request.args.get('next')
            if not next_page or url_parse(next_page).netloc != '':
                next_page = flask.url_for('admin')
            return flask.redirect(next_page)
    return flask.render_template('login.html', form=form)
def login ( ) : form = LoginForm ( ) if form . validate_on_submit ( ) : def fail ( ) : flask . flash ( "Invalid username or password" ) return flask . redirect ( flask . url_for ( 'login' ) ) try : user_obj = models . User ( email = form . email . data ) except Exception as e : return fail ( ) if not user_obj . check_password ( form . password . data ) : return fail ( ) else : user_obj . logger . info ( 'User authenticated! %s' % user_obj ) flask_login . login_user ( user_obj , remember = form . remember_me . data ) next_page = flask . request . args . get ( 'next' ) if not next_page or url_parse ( next_page ) . netloc != '' : next_page = flask . url_for ( 'admin' ) return flask . redirect ( next_page ) return flask . render_template ( 'login.html' , form = form )
We handle admin panel logins here.
We handle admin panel logins here .
""" We handle admin panel logins here. """ # unknown user # success--log the user in!