feat(frontend): check that the teacher is valid before setting the cookie
This commit is contained in:
parent
99be91941a
commit
b6ef022f15
@ -18,6 +18,7 @@ function load_teachers(id) {
|
||||
fetch(`/api/professori?id=${id}`)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
sessionStorage.setItem("teachers", JSON.stringify(data));
|
||||
let i = 0;
|
||||
data.forEach((el) => {
|
||||
const select = document.getElementById("teachers");
|
||||
@ -151,8 +152,13 @@ function load_major() {
|
||||
}
|
||||
|
||||
function select_teacher() {
|
||||
let teacher = document.getElementById("teacher").value;
|
||||
let teachers = JSON.parse(sessionStorage.getItem("teachers"));
|
||||
if (!teachers.includes(teacher)) {
|
||||
return false;
|
||||
}
|
||||
Cookies.set("type", "teacher");
|
||||
Cookies.set("teacher", document.getElementById("teacher").value);
|
||||
Cookies.set("teacher", teacher);
|
||||
}
|
||||
|
||||
function select_class() {
|
||||
|
Loading…
Reference in New Issue
Block a user