# Path: wikked/web.py
# def get_wiki():
# def uncaching_wiki_updater(wiki, url):
# def user_loader(username):
# def get_read_url(url):
# def get_edit_url(url):
# def get_rev_url(url, rev):
# def get_diff_url(url, rev1=None, rev2=None):
#     def async_updater(wiki):
#     def on_request_started(sender, **extra):
#     def on_request_tearing_down(sender, **extra):
# 
# Path: wikked/webimpl/admin.py
# def do_login_user():
#     username = request.form.get('username')
#     password = request.form.get('password')
#     remember = request.form.get('remember')
# 
#     wiki = get_wiki()
#     user = wiki.auth.getUser(username)
#     if user is not None and app.bcrypt:
#         if app.bcrypt.check_password_hash(user.password, password):
#             login_user(user, remember=bool(remember))
#             return True
#     return False


from flask import jsonify, abort, request
from flask_login import logout_user, current_user
from wikked.web import app, get_wiki
from wikked.webimpl.admin import do_login_user


@app.route('/api/user/login', methods=['POST'])
def api_user_login():
    if do_login_user():
        username = request.form.get('username')
        result = {'username': username, 'logged_in': 1}
        return jsonify(result)
    abort(401)


@app.route('/api/user/is_logged_in')
def api_user_is_logged_in():
    if current_user.is_authenticated():
        result = {'logged_in': True}
        return jsonify(result)
    abort(401)



# Path: wikked/web.py
# def get_wiki():
# def uncaching_wiki_updater(wiki, url):
# def user_loader(username):
# def get_read_url(url):
# def get_edit_url(url):
# def get_rev_url(url, rev):
# def get_diff_url(url, rev1=None, rev2=None):
#     def async_updater(wiki):
#     def on_request_started(sender, **extra):
#     def on_request_tearing_down(sender, **extra):
# 
# Path: wikked/webimpl/admin.py
# def do_login_user():
#     username = request.form.get('username')
#     password = request.form.get('password')
#     remember = request.form.get('remember')
# 
#     wiki = get_wiki()
#     user = wiki.auth.getUser(username)
#     if user is not None and app.bcrypt:
#         if app.bcrypt.check_password_hash(user.password, password):
#             login_user(user, remember=bool(remember))
#             return True
#     return False


# Path: wikked/api/user.py
from flask import jsonify, abort, request
from flask_login import logout_user, current_user
from wikked.web import app, get_wiki
from wikked.webimpl.admin import do_login_user



@app.route('/api/user/login', methods=['POST'])
def api_user_login():
    if do_login_user():
        username = request.form.get('username')
        result = {'username': username, 'logged_in': 1}
        return jsonify(result)
    abort(401)


@app.route('/api/user/is_logged_in')
def api_user_is_logged_in():
    if current_user.is_authenticated():
        result = {'logged_in': True}
        return jsonify(result)
    abort(401)



@app.route('/api/user/logout', methods=['POST'])