

@api.route('/login', methods=['POST'])
def login():
    if current_user.is_authenticated():
        return jsonify(flag='success')
    username = request.form.get('username')
    password = request.form.get('password')
    if (username and password):
        (user, authenticated) = User.authenticate(username, password)
        if (user and authenticated):
            if login_user(user, remember='y'):
                return jsonify(flag='success')
    current_app.logger.debug(('login(api) failed, username: %s.' % username))
    return jsonify(flag='fail', msg='Sorry, try again.')

dataset/ETHPy150Open imwilsonxu/fbone/fbone/api/views.py login/original