Skip to content

security issue-->added django decorator #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions judge/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from judge.models import Problem, Submission, Coder, TestCase
from judge.forms import UserForm, ProblemForm, SubmissionForm
from judge.tasks import evaluate_submission

from django.contrib.auth.decorators import login_required

def index(request):
return render(request, "judge/index.html")
Expand Down Expand Up @@ -54,7 +54,7 @@ def loguserin(request):
else:
return render(request, "judge/login.html", {})


@login_required
def loguserout(request):
if request.user.is_authenticated:
logout(request)
Expand Down Expand Up @@ -93,6 +93,7 @@ def all_problems(request):
problems = Problem.objects.all()
return render(request, "judge/all.html", {"problems":problems})

@login_required
def submit(request, pid):
if not request.user.is_authenticated:
return HttpResponseRedirect('/judge/login/')
Expand All @@ -113,6 +114,7 @@ def submit(request, pid):
payload = {"sub_form":sub_form, "pid":pid}
return render(request, "judge/submit.html", payload)

@login_required
def view_submission(request, submission_id):
required_sub = get_object_or_404(Submission, id = int(submission_id))
if not required_sub.private or (required_sub.private and required_sub.submitter.user.username == request.user.username):
Expand Down