Exemple #1
0
def logout():
    if request.method == 'POST':
        response = make_response(render_template('logout.html'))
        response = headers(response)
        cleanup()
        return response
    return redirect(url_for('login'))
Exemple #2
0
def history():
    if check_user():
        form = QueryHistory()
        username = session.get('user')['username']
        if check_admin():
            admin = True
            table, num_queries = get_queries(username)
            if form.validate_on_submit():
                username = form.username.data
                table, num_queries = get_queries(username, admin)
            response = make_response(
                render_template('history.html',
                                table=table,
                                num_queries=num_queries,
                                form=form,
                                username=username,
                                admin=admin))
        else:
            if request.method == 'GET':
                table, num_queries = get_queries(username)
                response = make_response(
                    render_template('history.html',
                                    table=table,
                                    num_queries=num_queries,
                                    username=username,
                                    form=form))
        response = headers(response)
        return response
    return redirect(url_for('login'))
Exemple #3
0
def register():
    form = Registration()
    if check_referrer() and form.validate_on_submit():
        username, password, phone = form.username.data, form.password.data, form.phone.data
        return register_with_user_info(username, password, phone)
    response = make_response(render_template('register.html', form=form))
    response = headers(response)
    return response
Exemple #4
0
def login():
    form = Login()
    if check_referrer() and form.validate_on_submit():
        username, password, phone = form.username.data, form.password.data, form.phone.data
        return verify_login(username, password, phone)
    response = make_response(render_template('login.html', form=form))
    response = headers(response)
    return response
Exemple #5
0
def login_history():
    form = LoginHistory()
    if check_admin() and form.validate_on_submit():
        username = form.username.data
        return get_logs(username)
    response = make_response(render_template('login_history.html', form=form))
    response = headers(response)
    return response
Exemple #6
0
def spell_check():
    form = SpellCheck()
    if check_user():
        if form.validate_on_submit():
            file_path = "text/samples/file.txt"
            return spell_check_user_input(form.input.data, file_path)
        response = make_response(render_template('spell_check.html', user=session['user']['username'], form=form))
        response = headers(response)
        return response
    return "CSRF attack thwarted"
Exemple #7
0
def user_query_history(username, id):
    if check_user():
        query_id, username, query_text, query_result = get_query(username, id)
        response = make_response(
            render_template('query.html',
                            query_id=query_id,
                            username=username,
                            query_text=query_text,
                            query_result=query_result))
        response = headers(response)
        return response
    return redirect(url_for('login'))
Exemple #8
0
def query(id):
    if check_user():
        username = session.get('user')['username']
        query_id, username, query_text, query_result = get_query(username, id)
        response = make_response(
            render_template('query.html',
                            query_id=query_id,
                            username=username,
                            query_text=query_text,
                            query_result=query_result))
        response = headers(response)
        return response
    return redirect(url_for('login'))