forked from apluslms/a-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d25bd9
commit 0de2bce
Showing
4 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as Cookies from "https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js" | ||
|
||
const copyToClipboard = (btnClassSelector, targetIdSelector) => { | ||
$(function() { | ||
var form = $("#gitmanager-form"); | ||
form.on("submit", function(event) { | ||
form.find('[type="submit"]').attr("disabled", true); | ||
form.find('.progress').removeClass("hidden"); | ||
}); | ||
}); | ||
|
||
$(function() { | ||
$("#gitmanager-link").on("click", async function(event) { | ||
event.preventDefault(); | ||
const csrftoken = Cookies.get('csrftoken'); | ||
var data = { | ||
"taud": "gitmanager", | ||
"exp": "01:00:00", | ||
"permissions": [ | ||
["instance", 1, {"id": 169}], | ||
["instance", 2, {"id": 169}] | ||
] | ||
}; | ||
|
||
var jsonData = JSON.stringify(data); | ||
|
||
const response = await fetch('http://localhost:8000/api/v2/get-token/', { | ||
method: 'POST', | ||
headers: {'X-CSRFToken': csrftoken, | ||
'Content-type': 'application/json' | ||
}, | ||
body: jsonData | ||
}); | ||
|
||
const resp_data = await response.json(); // Convert the data to JSON | ||
console.log(resp_data); // Logs the result in the console | ||
|
||
window.location = `https://gitmanager.cs.aalto.fi/login?referer=%2F&login=${encodeURIComponent(resp_data)}`; | ||
|
||
window.onload = function() { | ||
var token_field = document.getElementById('login-form'); | ||
token_field.value = resp_data; | ||
console.log(token_field.value); | ||
document.getElementById('login-form').submit(); | ||
}; | ||
|
||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters