Example #1
0
def report(request):
    if request.method == 'GET':
        if not check_csrf(request):
            return redirect('/404')
        post_id = request.args.get('id')
        instance = request.args.get('instance')
        if post_id.isdigit():
            botuser("http://127.0.0.1", instance, post_id)

    return redirect('/')
Example #2
0
def approve_follower(request):
    # TODO: Frontend support for the private acounts
    if request.method == 'GET':
        if not check_csrf(request):
            return redirect('/404')

        approver_username = request.session.get('username')
        follower_username = request.args.get('username')

        success, msg = add_follower(session, approver_username,
                                    follower_username)

        if success:
            return redirect('/')
        else:
            return redirect('/404')
Example #3
0
def report(request):
    if request.method == 'GET':
        post_id = request.args.get('id')
        instance = request.args.get('instance')
        if post_id.isdigit():
            botuser("http://127.0.0.1:5000", instance, post_id)

    return redirect('/')
Example #4
0
def login(request):
    if request.method == 'GET':
        return render_template('login.html', csrf=request.session['csrf'])

    if request.method == 'POST':
        if not check_csrf(request):
            return redirect('/404')
        success, msg = check_user(session, request.form['username'],
                                  request.form['password'])

        if success:
            request.session['username'] = request.form['username']
            request.session['name'] = msg
            return redirect('/')
        else:
            return render_template('login.html',
                                   error=msg,
                                   csrf=request.session['csrf'])
Example #5
0
def register(request):
    if request.method == 'GET':
        return render_template('register.html', csrf=request.session['csrf'])

    if request.method == 'POST':
        if not check_csrf(request):
            return redirect('/404')
        success, msg = add_user(session, request.form['username'],
                                request.form['fullname'],
                                request.form['password'],
                                request.form['confirm-password'])
        if success:
            request.session['username'] = request.form['username']
            request.session['name'] = request.form['fullname']
            return redirect('/')
        else:
            return render_template('register.html',
                                   error=msg,
                                   csrf=request.session['csrf'])
def newpost(request):
    post = request.form.get('submission-text')
    if (len(post) > 280):
        return redirect('/')

    preview = None
    link = None

    for word in post.split(' '):
        if word.startswith('[link]'):
            link = " ".join(word.split('[link]')[1:]).strip()
            if verified_user(session, request.session.get('username'))[0]:
                preview = get_post_preview(link)
            link = link
            break

    post = post.replace('[link]', '')

    add_post(session, request.session.get('username'), post, link, preview)

    return redirect('/')
 def decorated_func(*args, **kwargs):
     uname = args[0].session.get('username')
     if not uname or not user_exists(session, uname)[0]:
         return redirect('/login')
     return f(*args, **kwargs)
def logout(request):
    request.session['username'] = None
    return redirect('/login')
Example #9
0
def logout(request):
    if not check_csrf(request):
        return redirect('/404')
    request.session['username'] = None
    return redirect('/login')