Skip to content

Commit 2981096

Browse files
authored
Merge pull request #11 from pyobs/develop
Develop
2 parents 6011947 + b614a3b commit 2981096

File tree

3 files changed

+7
-45
lines changed

3 files changed

+7
-45
lines changed

pyobs_archive/authentication/backends.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class BearerAuthentication(authentication.BaseAuthentication):
4949
the odin auth server
5050
"""
5151
def authenticate(self, request):
52-
print('bearer')
5352
auth_header = request.META.get('HTTP_AUTHORIZATION', '')
5453
if 'Bearer' not in auth_header:
5554
return None

pyobs_archive/frontend/static/js/app.js

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ $(function () {
8282
field: 'basename',
8383
title: 'Name',
8484
sortable: true,
85-
formatter: function(value, row) {
85+
formatter: function (value, row) {
8686
let url = '/frames/' + row.id + '/download/';
8787
return '<a href="' + url + '">' + value + '.fits.fz</a>';
8888
}
@@ -259,39 +259,6 @@ $(function () {
259259
history.pushState({}, '', '?q=a' + buildQueryParms());
260260
}
261261

262-
function login(username, password, callback) {
263-
$.post('/api-token-auth/', {
264-
'username': username,
265-
'password': password
266-
}).done(function (data) {
267-
localStorage.setItem('token', data.token);
268-
callback(true);
269-
}).fail(function () {
270-
callback(false);
271-
});
272-
}
273-
274-
function logout() {
275-
localStorage.removeItem('token');
276-
}
277-
278-
$('#login').click(function () {
279-
login($('#email').val(), $('#password').val(), function (result) {
280-
if (result) {
281-
$('#login-form').hide();
282-
$('#alert').alert('close');
283-
$('#logout').show();
284-
refreshTable();
285-
} else {
286-
if ($("#alert-error").find("div#alert").length == 0) {
287-
$("#alert-error").append("<div class='alert alert-danger alert-dismissable' id='alert'>" +
288-
"<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button> " +
289-
"Login failed.</div>");
290-
}
291-
}
292-
});
293-
});
294-
295262
$('.keyup').typeWatch({
296263
callback: function callback() {
297264
refreshTable();
@@ -301,13 +268,6 @@ $(function () {
301268
captureLength: 1
302269
});
303270

304-
$('#logout').click(function () {
305-
logout();
306-
$('#login-form').show();
307-
$('#logout').hide();
308-
refreshTable();
309-
});
310-
311271
if (localStorage.getItem('token') !== null) {
312272
$('#login-form').hide();
313273
$('#logout').show();
@@ -379,10 +339,10 @@ $(function () {
379339
});
380340

381341
if (frames.length > 0) {
342+
let token = $("#zip-form").find('input[name=csrfmiddlewaretoken]').val()
382343
$.fileDownload('/frames/zip/', {
383344
httpMethod: 'POST',
384-
data: {'frame_ids': frames, 'auth_token': localStorage.getItem('token')},
385-
headers: {}
345+
data: {'frame_ids': frames, csrfmiddlewaretoken: token}
386346
});
387347
}
388348
}

pyobs_archive/frontend/templates/archive/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@
8282
<div class="form-inline">
8383
<div class="form-group form-inline">
8484
<div class="btn-toolbar" role="group">
85-
<button id="downloadBtn" class="btn btn-primary">Download</button>
85+
<form id="zip-form">
86+
{% csrf_token %}
87+
<button type="button" id="downloadBtn" class="btn btn-primary">Download</button>
88+
</form>
8689
</div>
8790
</div>
8891
</div>

0 commit comments

Comments
 (0)