Commit 0066cfc7 by x

Fixed Labor gui (csrf token cookie not presented)

parent 666997e9
...@@ -23,6 +23,7 @@ from one.models import * ...@@ -23,6 +23,7 @@ from one.models import *
from school.models import * from school.models import *
import django.contrib.auth as auth import django.contrib.auth as auth
import logging import logging
from django.views.decorators.csrf import ensure_csrf_cookie
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -30,6 +31,7 @@ def logout(request): ...@@ -30,6 +31,7 @@ def logout(request):
auth.logout(request) auth.logout(request)
return redirect('/Shibboleth.sso/Logout?return=https%3a%2f%2fcloud.ik.bme.hu%2f') return redirect('/Shibboleth.sso/Logout?return=https%3a%2f%2fcloud.ik.bme.hu%2f')
@ensure_csrf_cookie
def login(request): def login(request):
try: try:
user = User.objects.get(username=request.META['niifPersonOrgID']) user = User.objects.get(username=request.META['niifPersonOrgID'])
......
...@@ -16,6 +16,9 @@ class StoreApi: ...@@ -16,6 +16,9 @@ class StoreApi:
# ssl_auth = True # ssl_auth = True
# verify_ssl = False # verify_ssl = False
@staticmethod @staticmethod
def get_host():
return settings['store_host']
@staticmethod
def post_request(url, payload): def post_request(url, payload):
headers = {'content-type': 'application/json'} headers = {'content-type': 'application/json'}
if settings['ssl_auth'] == 'True' and settings['basic_auth'] == 'True': if settings['ssl_auth'] == 'True' and settings['basic_auth'] == 'True':
......
...@@ -22,7 +22,8 @@ function postKey(key) { ...@@ -22,7 +22,8 @@ function postKey(key) {
function (respond) { function (respond) {
alert(respond); alert(respond);
} }
); )
.error(function (respond) { alert(JSON.stringify(respond)); });
} }
function resetKey() { function resetKey() {
$.post("/store/gui/", "", $.post("/store/gui/", "",
......
# Create your views here. # Create your views here.
from django.core.context_processors import csrf
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect from django.shortcuts import render_to_response, redirect
from django.template import RequestContext from django.template import RequestContext
...@@ -122,10 +123,11 @@ def toplist(request): ...@@ -122,10 +123,11 @@ def toplist(request):
file_list = StoreApi.toplist(user) file_list = StoreApi.toplist(user)
return render_to_response('store/list.html', RequestContext(request, {'file_list': file_list, 'path' : path, 'backpath' : backpath, 'username' : user})) return render_to_response('store/list.html', RequestContext(request, {'file_list': file_list, 'path' : path, 'backpath' : backpath, 'username' : user}))
@login_required
def gui(request): def gui(request):
user = request.user.username user = request.user.username
if request.method == 'GET': if request.method == 'GET':
return render_to_response('store/gui.html', RequestContext(request, {'username' : user, 'host' : '10.9.1.86'})) return render_to_response('store/gui.html', RequestContext(request, {'username' : user, 'host' : StoreApi.get_host()}))
elif request.method == 'POST': elif request.method == 'POST':
try: try:
details = request.user.userclouddetails_set.all()[0] details = request.user.userclouddetails_set.all()[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment