sending only needed request
(implemented is_admin from 1/2)
This commit is contained in:
parent
d5c1e3c13f
commit
69824f6886
@ -53,20 +53,37 @@ function inject_info(id, username, postfix)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_user(old_username, username, nickname, admin, sex, bio, refresh)
|
async function update_user(old_username, username, nickname, admin, sex, bio, refresh)
|
||||||
{
|
{
|
||||||
|
let am_i_admin = await is_admin();
|
||||||
|
|
||||||
$.ajax
|
$.ajax
|
||||||
({
|
({
|
||||||
url: "./res/forum/api/update_user.php" +
|
url: "./res/forum/api/update_user.php" +
|
||||||
"?old_username=" + old_username +
|
"?old_username=" + old_username +
|
||||||
"&username=" + username +
|
|
||||||
"&nickname=" + nickname +
|
"&nickname=" + nickname +
|
||||||
"&admin=" + admin +
|
|
||||||
"&sex=" + sex +
|
"&sex=" + sex +
|
||||||
"&bio=" + bio,
|
"&bio=" + bio +
|
||||||
|
((am_i_admin) ? "&username=" + username +
|
||||||
|
"&admin=" + admin : ""),
|
||||||
success: function(result)
|
success: function(result)
|
||||||
{
|
{
|
||||||
show(refresh);
|
show(refresh);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_admin()
|
||||||
|
{
|
||||||
|
return new Promise(function(resolve)
|
||||||
|
{
|
||||||
|
$.ajax
|
||||||
|
({
|
||||||
|
url: "./res/forum/api/is_admin.php",
|
||||||
|
success: function(result)
|
||||||
|
{
|
||||||
|
resolve(result.admin);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
@ -20,7 +20,7 @@
|
|||||||
url: "./res/forum/api/get_username.php",
|
url: "./res/forum/api/get_username.php",
|
||||||
success: function(result)
|
success: function(result)
|
||||||
{
|
{
|
||||||
update_user(result.username, document.getElementById("username").value, document.getElementById("nickname").value, document.getElementById("admin").value, document.getElementById("sex").value,document.getElementById("bio").value, "user");
|
update_user(result.username, null, document.getElementById("nickname").value, null, document.getElementById("sex").value,document.getElementById("bio").value, "user");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user